Intégration continue
Selon tous les conseils dispersés ci-dessus, nous partons sur une configuration avec Ruff, Black, Pytest, isort, Coverage et Poetry.
Toute la complexité va se trouver dans le fichier pyproject.toml
:
[tool.black]line-length = 100
[tool.ruff]line-length = 100extend-exclude = [ "**/migrations/**"]
extend-select = [ "I", # Missing required import (auto-fixable) "UP", # Pyupgrade "RUF100", # Unused noqa (auto-fixable) # We ignore more pydocstyle than we enable, so be more selective at what we enable "D101", "D106", "D2", "D3", "D400", # "D401", # Not enabled by ruff, but we don't want it "D402", "D403", "D412", "D419", "TCH", # Rules around TYPE_CHECKING blocks "TID251", # Specific modules or module members that may not be imported or accessed "TID253", # Ban certain modules from being imported at module level "ISC", # Checks for implicit literal string concatenation (auto-fixable) "B006", # Checks for uses of mutable objects as function argument defaults.]ignore = [ "D203", "D212", "D213", "D214", "D215", "E731", "TCH003", # Do not move imports from stdlib to TYPE_CHECKING block]
[tool.ruff.format]docstring-code-format = true
[tool.pytest.ini_options]python_files = [ "test_*.py", "example_*.py",]testpaths = [ "tests",]
[tool.ruff.isort]required-imports = ["from __future__ import annotations"]combine-as-imports = true
Coverage
[tool.coverage.run]branch = truerelative_files = truesource = ["airflow"]omit = [ "airflow/_vendor/**", "airflow/contrib/**", "airflow/example_dags/**", "airflow/migrations/**", "airflow/providers/**/example_dags/**", "airflow/www/node_modules/**", "airflow/providers/google/ads/_vendor/**",]
[tool.coverage.report]skip_empty = trueexclude_also = [ "def __repr__", "raise AssertionError", "raise NotImplementedError", "if __name__ == .__main__.:", "@(abc\\.)?abstractmethod", "@(typing(_extensions)?\\.)?overload", "if (typing(_extensions)?\\.)?TYPE_CHECKING:"]
Mypy
[tool.mypy]ignore_missing_imports = trueno_implicit_optional = truewarn_redundant_casts = truewarn_unused_ignores = falseplugins = [ "dev/mypy/plugin/decorators.py", "dev/mypy/plugin/outputs.py",]pretty = trueshow_error_codes = truedisable_error_code = [ "annotation-unchecked",]
[[tool.mypy.overrides]]module="airflow.config_templates.default_webserver_config"disable_error_code = [ "var-annotated",]
[[tool.mypy.overrides]]module="airflow.migrations.*"ignore_errors = true
[[tool.mypy.overrides]]module= [ "google.cloud.*", "azure.*",]no_implicit_optional = false
[[tool.mypy.overrides]]module=[ "referencing.*", # Beam has some old type annotations, and they introduced an error recently with bad signature of # a function. This is captured in https://github.com/apache/beam/issues/29927 # and we should remove this exclusion when it is fixed. "apache_beam.*"]ignore_errors = true
setup.cfg
→ Faire le lien avec les settings → Faire le lien avec les douze facteurs → Construction du fichier setup.cfg
[flake8] max-line-length = 100 exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv
[pycodestyle] max-line-length = 100 exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv
[mypy] python_version = 3.8 check_untyped_defs = True ignore_missing_imports = True warn_unused_ignores = True warn_redundant_casts = True warn_unused_configs = True plugins = mypy_django_plugin.main
[mypy.plugins.django-stubs] django_settings_module = config.settings.test
[mypy-*.migrations.*] # Django migrations should not produce any errors: ignore_errors = True
[coverage:run] include = khana/* omit = *migrations*, *tests* plugins = django_coverage_plugin
Mypy + black + pylint + flake8 + pyflakes + …