diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2b685e3..72d0e6e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,19 +27,24 @@ repos: - repo: https://github.com/adamchainz/django-upgrade rev: 1.17.0 hooks: - - id: django-upgrade - args: [--target-version, "4.2"] - alias: autoformat - - repo: https://github.com/psf/black - rev: 24.4.2 + - id: django-upgrade + args: [--target-version, "5.0"] + - repo: https://github.com/asottile/pyupgrade + rev: v3.15.2 hooks: - - id: black - alias: autoformat - - repo: https://github.com/charliermarsh/ruff-pre-commit + - id: pyupgrade + args: [--py312-plus] + - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.4.5 hooks: - id: ruff - alias: autoformat + args: [--fix] + - id: ruff-format + - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks + rev: v2.13.0 + hooks: + - id: pretty-format-toml + args: [--autofix] - repo: https://github.com/asottile/blacken-docs rev: 1.16.0 hooks: diff --git a/manage.py-tpl b/manage.py-tpl index 68141ee..aabb818 100755 --- a/manage.py-tpl +++ b/manage.py-tpl @@ -1,22 +1,23 @@ #!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" + import os import sys -if __name__ == "__main__": + +def main(): + """Run administrative tasks.""" os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings") try: from django.core.management import execute_from_command_line - except ImportError: - # The above import may fail for some other reason. Ensure that the - # issue is really that Django is missing to avoid masking other - # exceptions on Python 2. - try: - import django - except ImportError: - raise ImportError( - "Couldn't import Django. Are you sure it's installed and " - "available on your PYTHONPATH environment variable? Did you " - "forget to activate a virtual environment?" - ) - raise + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc execute_from_command_line(sys.argv) + + +if __name__ == "__main__": + main() diff --git a/pyproject.toml b/pyproject.toml index 361a24e..57b393e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,56 +3,52 @@ target-version = ["py312"] [tool.coverage.run] omit = [ - "*/admin.py", - "*/manage.py", - "*/migrations/*", - "*/tests/*", - "conftest.py", + "*/admin.py", + "*/manage.py", + "*/migrations/*", + "*/tests/*", + "conftest.py" ] [tool.pytest.ini_options] -addopts = "--cov --nomigrations --reuse-db" DJANGO_SETTINGS_MODULE = "config.settings" +addopts = "--cov --nomigrations --reuse-db" norecursedirs = ".git* frontend requirements templates" python_files = "test_*.py" [tool.ruff] -# Enable Pyflakes `E` and `F` codes by default. -select = ["E", "F"] -ignore = ["E501", "E741"] # temporary - -# Allow autofix for all enabled rules (when `--fix`) is provided. -fixable = ["A", "B", "C", "D", "E", "F"] -unfixable = [] - # Exclude a variety of commonly ignored directories. exclude = [ - ".bzr", - ".direnv", - ".eggs", - ".git", - ".github", - ".hg", - ".ruff_cache", - ".svn", - ".tox", - ".venv", - "__pypackages__", - "_build", - "build", - "dist", - "migrations", - "node_modules", - "static", + ".bzr", + ".direnv", + ".eggs", + ".git", + ".github", + ".hg", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + "__pypackages__", + "_build", + "build", + "dist", + "migrations", + "node_modules", + "static" ] - -per-file-ignores = {} - # Same as Black. line-length = 120 +# Assume Python 3.12. +target-version = "py312" +[tool.ruff.lint] # Allow unused variables when underscore-prefixed. dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" - -# Assume Python 3.12. -target-version = "py312" +# Allow autofix for all enabled rules (when `--fix`) is provided. +fixable = ["A", "B", "C", "D", "E", "F"] +ignore = ["E501", "E741"] # temporary +per-file-ignores = {} +# Enable Pyflakes `E` and `F` codes by default. +select = ["E", "F"] +unfixable = []