diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c02729fa42..aa697186d0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,7 @@ repos: - id: ruff-format - repo: https://github.com/tox-dev/pyproject-fmt - rev: "v2.7.0" + rev: "v2.8.0" hooks: - id: pyproject-fmt diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index 509610b630..b939e86eba 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -44,6 +44,11 @@ repos: # Formatter - id: ruff-format + - repo: https://github.com/tox-dev/pyproject-fmt + rev: v2.8.0 + hooks: + - id: pyproject-fmt + - repo: https://github.com/Riverside-Healthcare/djLint rev: v1.36.4 hooks: diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index fbf8aff048..995ed3c1d5 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -1,22 +1,120 @@ +[project] +name = "{{ cookiecutter.project_slug }}" +version = "{{ cookiecutter.version }}" +description = "{{ cookiecutter.description }}" +readme = "README.md" +license = { text = "{{ cookiecutter.open_source_license }}" } +authors = [ + { name = "{{ cookiecutter.author_name }}", email = "{{ cookiecutter.email }}" }, +] +requires-python = "==3.13.*" +classifiers = [ + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.13", +] +dependencies = [ + {# set the an initial indentation for uv to follow #} + "django", +] + +[dependency-groups] +dev = [ + {# set the an initial indentation for uv to follow #} + "pytest", +] + +[tool.ruff] +# Exclude a variety of commonly ignored directories. +extend-exclude = [ + "*/migrations/*.py", + "staticfiles/*", +] + +lint.select = [ + "A", + "ASYNC", + "B", + "BLE", + "C4", + "C90", + "COM", + "DJ", + "DTZ", + "E", + "EM", + "ERA", + "EXE", + "F", + "FA", + "FBT", + "FLY", + "G", + "I", + "ICN", + "INP", + "INT", + "ISC", + "N", + "PD", + "PERF", + "PGH", + "PIE", + "PL", + "PT", + "PTH", + "PYI", + "Q", + "RET", + "RSE", + "RUF", + "S", + "SIM", + "SLF", + "SLOT", + "T10", + "T20", + "TC", + "TID", + "TRY", + "UP", + "W", + "YTT", +] +lint.ignore = [ + "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` + "S101", # Use of assert detected https://docs.astral.sh/ruff/rules/assert/ + "SIM102", # sometimes it's better to nest + # of types for comparison. + # Deactivated because it can make the code slow: + # https://github.com/astral-sh/ruff/issues/7871 +] +lint.isort.force-single-line = true + +[tool.pyproject-fmt] +keep_full_version = true + # ==== pytest ==== + [tool.pytest.ini_options] minversion = "6.0" addopts = "--ds=config.settings.test --reuse-db --import-mode=importlib" python_files = [ - "tests.py", - "test_*.py", + "tests.py", + "test_*.py", ] {%- if cookiecutter.frontend_pipeline == 'Gulp' %} -norecursedirs = ["node_modules"] +norecursedirs = [ "node_modules" ] {%- endif %} # ==== Coverage ==== + [tool.coverage.run] -include = ["{{cookiecutter.project_slug}}/**"] -omit = ["*/migrations/*", "*/tests/*"] -plugins = ["django_coverage_plugin"] +include = [ "{{cookiecutter.project_slug}}/**" ] +omit = [ "*/migrations/*", "*/tests/*" ] +plugins = [ "django_coverage_plugin" ] # ==== mypy ==== + [tool.mypy] python_version = "3.13" check_untyped_defs = true @@ -25,10 +123,10 @@ 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_django_plugin.main", + {%- if cookiecutter.use_drf == "y" %} + "mypy_drf_plugin.main", + {%- endif %} ] [[tool.mypy.overrides]] @@ -40,6 +138,7 @@ ignore_errors = true django_settings_module = "config.settings.test" # ==== djLint ==== + [tool.djlint] blank_line_after_tag = "load,extends" close_void_tags = true @@ -57,95 +156,3 @@ indent_size = 2 [tool.djlint.js] indent_size = 2 - -[tool.ruff] -# Exclude a variety of commonly ignored directories. -extend-exclude = [ - "*/migrations/*.py", - "staticfiles/*", -] - -[tool.ruff.lint] -select = [ - "F", - "E", - "W", - "C90", - "I", - "N", - "UP", - "YTT", - # "ANN", # flake8-annotations: we should support this in the future but 100+ errors atm - "ASYNC", - "S", - "BLE", - "FBT", - "B", - "A", - "COM", - "C4", - "DTZ", - "T10", - "DJ", - "EM", - "EXE", - "FA", - 'ISC', - "ICN", - "G", - 'INP', - 'PIE', - "T20", - 'PYI', - 'PT', - "Q", - "RSE", - "RET", - "SLF", - "SLOT", - "SIM", - "TID", - "TC", - "INT", - # "ARG", # Unused function argument - "PTH", - "ERA", - "PD", - "PGH", - "PL", - "TRY", - "FLY", - # "NPY", - # "AIR", - "PERF", - # "FURB", - # "LOG", - "RUF", -] -ignore = [ - "S101", # Use of assert detected https://docs.astral.sh/ruff/rules/assert/ - "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` - "SIM102", # sometimes it's better to nest - # of types for comparison. - # Deactivated because it can make the code slow: - # https://github.com/astral-sh/ruff/issues/7871 -] - -[tool.ruff.lint.isort] -force-single-line = true - -[dependency-groups] -dev = [] - -[project] -name = "{{ cookiecutter.project_slug }}" -version = "{{ cookiecutter.version }}" -description = "{{ cookiecutter.description }}" -readme = "README.md" - -license = { text = "{{ cookiecutter.open_source_license }}" } -authors = [ - { name = "{{ cookiecutter.author_name }}", email = "{{ cookiecutter.email }}" }, -] -requires-python = "==3.13.*" -dependencies = []