Create sharable configuration presets for Flake8
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
Línea de trabajo
Comienza rastreando la carga de configuración de flake8 y el manejo de las opciones de línea de comandos; después, revisa el punto de entrada propuesto de setup.py bajo flake8.configuration y la API de ConfigurationClass. Se considera terminado cuando se puede seleccionar una configuración compartible instalada con --sharable-configuration, mientras que los indicadores de CLI y la configuración de setup.cfg/.flake8 conservan una prioridad mayor.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
In GitLab by @sobolevn on Jul 20, 2019, 02:35
Problem
I am writing quite a complex plugin with lots of configuration options.
Moreover, I also depend on a lot of other plugins as dependencies.
Here's how my configuration looks like for an end user, contents of setup.cfg:
[flake8]
# Base flake8 configuration:
format = wemake
show-source = True
statistics = False
doctests = True
enable-extensions = G
# Plugins:
accept-encodings = utf-8
max-complexity = 6
max-line-length = 80
quotes = single
# Self settings:
max-imports = 14
# Exclude some pydoctest checks globally:
ignore = D100, D104, D401, W504, RST303, RST304
[isort]
# See https://github.com/timothycrosley/isort#multi-line-output-modes
multi_line_output = 3
include_trailing_comma = true
default_section = FIRSTPARTY
# Is the same as 80 in flake8:
line_length = 79
Notice, that I also use flake8-isort and [isort] option, there also might be other sections like [mypy] for flake8-mypy, or [bandit] for flake8-bandit or any other plugins when flake8 acts like a wrapper for other tools.
Currently, we will only talk about [flake8] section, since sadly we are not responsible for other tools.
I do not want my users to copy-paste these settings for several reasons:
- They usually make mistakes in this simple action :slight_smile:
- I am losing control over the default configuration: I will not be able to change something in their defaults even if I want to
- It brings a lot of copy-paste. That's totally inconvenient to use and maintain. One new feature or a bug might force you to go trough all your X project and edit the configuration.
Real world use-cases
Several other linters have this feature. Some of them even consider it as a key feature.
- EsLint: https://eslint.org/docs/developer-guide/shareable-configs
- TsLint: https://palantir.github.io/tslint/2016/03/31/sharable-configurations-rules.html
- Stylelint: https://stylelint.io/user-guide/configuration
- Rubocop: https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md#inheriting-configuration-from-a-dependency-gem
When working for EsLint for example, one can just create a module with a single javascript file and reuse it everywhere.
I propose the same for flake8.
Each user can create its own set of rules for an organisation / set of projects and reuse it without this amount of copy-paste.
Implementation details
Things to point out:
- It is not a breaking change, everything so work as-is, no major version bump is required
- Without new feature everything should work as-is
- New configuration option should take the lowest priority over existing config options
Configuration priority
Higher takes the priority over lower:
- CLI flags
setup.cfg/.flake8- New option:
--sharable-configuration
Creating new sharable configuration
I guess that reusing entry points here is the best option.
# setup.py
# ...
setup(
name='my-flake8-config'
entry_points={
'flake8.configuration': [
'myconfig = some.path:ConfigurationClass',
],
},
Then:
- Installing:
pip install my-flake8-config - Running:
flake8 --sharable-configuration=myconfig - Done!
Configuration class API
I am not sure about this. But my vision would be something like:
# some/path.py
class ConfigurationClass(object):
def sharable_configuration(self):
return {
'quotes': 'single',
# and any other options for `[flake8]` section
}
Conclusion
This feature allows to transfer configuration in a reliable and clean way, brings no breaking changes, follows the best practices of other lint tools.
Original issue from wemake-python-styleguide: https://github.com/wemake-services/wemake-python-styleguide/issues/164
The same feature I proposed for isort: https://github.com/timothycrosley/isort/issues/970
I am super excited to help!
- Lenguaje dominante
- Python
- Estrellas
- 3.8k
- Forks
- 363
- Merge medio
- 3 h 59 min
- PR fusionados (30 d)
- 11
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de PyCQA/flake8
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
PyCQA/flake8#2062 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
Max Line Length in style guide ignored with python 3.14 when checking multiple filesQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
PyCQA/flake8#2011 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
PyCQA/flake8#1793 · 9 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
PyCQA/flake8#1774 · 13 comentarios ·
Los mantenedores suelen responder en 1 día
-
option_manager.add_option ignores action when reading from configQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
PyCQA/flake8#1770 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de PyCQA/flake8
Issues similares
-
idxmax/idxmin raise ValueError when a single partition is all-NAPosiblemente ocupada @Jason10191019999 la tomó hoy. Abiertoneeds triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 3 días
-
Old versions of datamodelsAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
-
[BUG]: Windows GUI package of v1.17.0-rc3 has no GTK DLLsPosiblemente ocupada @andrut-ds la tomó hoy. Abiertobug CI/CD Pactus-GUI Windows
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
pactus-project/pactus#2428 ·
Los mantenedores suelen responder en 1 día
-
DiskDataset.reshard() can hang with a zero or negative shard sizePosiblemente ocupada @Programmer-Develops la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 19 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
GNS3/gns3-server#3017 · 1 comentario ·
Los mantenedores suelen responder en 1 día