diff --git a/.flake8 b/.flake8 new file mode 100644 index 000000000..84b4b4411 --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] +exclude = docs +max-line-length = 119 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..2b4b98783 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,29 @@ +# ==== pytest ==== +[tool.pytest.ini_options] +addopts = "-v --tb=short" +norecursedirs = [ + ".tox", + ".git", + "*/migrations/*", + "*/static/*", + "docs", + "venv", + "*/{{cookiecutter.project_slug}}/*", +] + + +# ==== black ==== +[tool.black] +line-length = 119 +target-version = ['py311'] + + +# ==== isort ==== +[tool.isort] +profile = "black" +line_length = 119 +known_first_party = [ + "tests", + "scripts", + "hooks", +] diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 52506f47d..000000000 --- a/pytest.ini +++ /dev/null @@ -1,3 +0,0 @@ -[pytest] -addopts = -v --tb=short -norecursedirs = .tox .git */migrations/* */static/* docs venv */{{cookiecutter.project_slug}}/* diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index dd8f1ef3c..000000000 --- a/setup.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[flake8] -exclude = docs -max-line-length = 88 - -[isort] -profile = black -known_first_party = tests,scripts,hooks diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index a7c8fa583..5d8670e4a 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -44,8 +44,6 @@ repos: rev: 6.0.0 hooks: - id: flake8 - args: ['--config=setup.cfg'] - additional_dependencies: [flake8-isort] # sets up .pre-commit-ci.yaml to ensure pre-commit dependencies stay up to date ci: diff --git a/{{cookiecutter.project_slug}}/.pylintrc b/{{cookiecutter.project_slug}}/.pylintrc deleted file mode 100644 index 9d604334b..000000000 --- a/{{cookiecutter.project_slug}}/.pylintrc +++ /dev/null @@ -1,14 +0,0 @@ -[MASTER] -load-plugins=pylint_django{% if cookiecutter.use_celery == "y" %}, pylint_celery{% endif %} -django-settings-module=config.settings.local -[FORMAT] -max-line-length=120 - -[MESSAGES CONTROL] -disable=missing-docstring,invalid-name - -[DESIGN] -max-parents=13 - -[TYPECHECK] -generated-members=REQUEST,acl_users,aq_parent,"[a-zA-Z]+_set{1,2}",save,delete diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml new file mode 100644 index 000000000..6acac9b2c --- /dev/null +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -0,0 +1,92 @@ +# ==== pytest ==== +[tool.pytest.ini_options] +minversion = "6.0" +addopts = "--ds=config.settings.test --reuse-db" +python_files = [ + "tests.py", + "test_*.py", +] +{%- if cookiecutter.frontend_pipeline == 'Gulp' %} +norecursedirs = ["node_modules"] +{%- endif %} + +# ==== Coverage ==== +[tool.coverage.run] +include = ["{{cookiecutter.project_slug}}/**"] +omit = ["*/migrations/*", "*/tests/*"] +plugins = ["django_coverage_plugin"] + + +# ==== black ==== +[tool.black] +line-length = 119 +target-version = ['py311'] + + +# ==== isort ==== +[tool.isort] +profile = "black" +line_length = 119 +known_first_party = [ + "{{cookiecutter.project_slug}}", + "config", +] +skip = ["venv/"] +skip_glob = ["**/migrations/*.py"] + + +# ==== mypy ==== +[tool.mypy] +python_version = "3.11" +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", +{%- if cookiecutter.use_drf == "y" %} + "mypy_drf_plugin.main", +{%- endif %} +] + +[[tool.mypy.overrides]] +# Django migrations should not produce any errors: +module = "*.migrations.*" +ignore_errors = true + +[tool.django-stubs] +django_settings_module = "config.settings.test" + + +# ==== PyLint ==== +[tool.pylint.MASTER] +load-plugins = [ + "pylint_django", +{%- if cookiecutter.use_celery == "y" %} + "pylint_celery", +{%- endif %} +] +django-settings-module = "config.settings.local" + +[tool.pylint.FORMAT] +max-line-length = 119 + +[tool.pylint."MESSAGES CONTROL"] +disable = [ + "missing-docstring", + "invalid-name", +] + +[tool.pylint.DESIGN] +max-parents = 13 + +[tool.pylint.TYPECHECK] +generated-members = [ + "REQUEST", + "acl_users", + "aq_parent", + "[a-zA-Z]+_set{1,2}", + "save", + "delete", +] diff --git a/{{cookiecutter.project_slug}}/pytest.ini b/{{cookiecutter.project_slug}}/pytest.ini deleted file mode 100644 index 969c7921e..000000000 --- a/{{cookiecutter.project_slug}}/pytest.ini +++ /dev/null @@ -1,6 +0,0 @@ -[pytest] -addopts = --ds=config.settings.test --reuse-db -python_files = tests.py test_*.py -{%- if cookiecutter.frontend_pipeline == 'Gulp' %} -norecursedirs = node_modules -{%- endif %} diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg index ab191732b..829064213 100644 --- a/{{cookiecutter.project_slug}}/setup.cfg +++ b/{{cookiecutter.project_slug}}/setup.cfg @@ -1,40 +1,10 @@ +# flake8 and pycodestyle don't support pyproject.toml +# https://github.com/PyCQA/flake8/issues/234 +# https://github.com/PyCQA/pycodestyle/issues/813 [flake8] -max-line-length = 120 +max-line-length = 119 exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv,.venv [pycodestyle] -max-line-length = 120 +max-line-length = 119 exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv,.venv - -[isort] -line_length = 88 -known_first_party = {{cookiecutter.project_slug}},config -multi_line_output = 3 -default_section = THIRDPARTY -skip = venv/ -skip_glob = **/migrations/*.py -include_trailing_comma = true -force_grid_wrap = 0 -use_parentheses = true - -[mypy] -python_version = 3.11 -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{% if cookiecutter.use_drf == "y" %}, mypy_drf_plugin.main{% endif %} - -[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 = {{cookiecutter.project_slug}}/** -omit = */migrations/*, */tests/* -plugins = - django_coverage_plugin