diff --git a/.gitignore b/.gitignore index 0ede2ddf..3d0b061c 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,7 @@ celerybeat-schedule #other .flake8 +.ruff_cache .pylintrc Makefile alliance_auth.sqlite3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 01bb6c7d..dc329454 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,14 +4,14 @@ # pre-commit autoupdate repos: - # Code Upgrades - - repo: https://github.com/asottile/pyupgrade - rev: v3.15.2 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.4 hooks: - - id: pyupgrade - args: [--py310-plus] + # Run the linter, and only the linter + - id: ruff + - repo: https://github.com/adamchainz/django-upgrade - rev: 1.17.0 + rev: 1.21.0 hooks: - id: django-upgrade args: [--target-version=4.2] @@ -63,7 +63,7 @@ repos: swagger\.json ) - repo: https://github.com/editorconfig-checker/editorconfig-checker.python - rev: 2.7.3 + rev: 3.0.3 hooks: - id: editorconfig-checker exclude: | @@ -82,7 +82,7 @@ repos: - --disable=MD013 # Infrastructure - repo: https://github.com/tox-dev/pyproject-fmt - rev: 2.1.3 + rev: 2.2.3 hooks: - id: pyproject-fmt name: pyproject.toml formatter @@ -90,9 +90,9 @@ repos: args: - --indent=4 additional_dependencies: - - tox==4.15.0 # https://github.com/tox-dev/tox/releases/latest + - tox==4.18.1 # https://github.com/tox-dev/tox/releases/latest - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.18 + rev: v0.19 hooks: - id: validate-pyproject name: Validate pyproject.toml diff --git a/pyproject.toml b/pyproject.toml index b402051c..68092df9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,6 +85,47 @@ scripts.allianceauth = "allianceauth.bin.allianceauth:main" [tool.flit.module] name = "allianceauth" +[tool.ruff] +line-length = 119 +format.line-ending = "lf" +lint.select = [ + "B", # flake8-bugbear + "C", # pylint convention + # "D", # pydocstyle, Want to turn these on, but our docstrings are lightly used + "D300", # use triple double-quotes in docstrings PEP 257 + "DJ", # flake8-django + "DOC", # pylintdoc + "E", # pycodestyle error + "F", # pyflakes (flake8 base) + "G010", # logging-warn, Warn on using logging.warn + "I", # isort + "PGH005", # pygrep-hooks, python-check-mock-method + "RUF100", # basically yesqa + "UP", # pyupgrade, will target requires-python + "W", # pycodestyle Warning +] +lint.ignore = [ + "E501", # Line too long, WIP across repo. +] +lint.isort.combine-as-imports = true # profile=django +lint.isort.section-order = [ + "future", + "standard-library", + "third-party", + "DJANGO", + "ESI", + "first-party", + "local-folder", +] +lint.isort.sections."DJANGO" = [ + "django", + "django_redis", + "django_registration", +] +lint.isort.sections."ESI" = [ + "esi", +] + [tool.isort] profile = "django" sections = [ @@ -99,7 +140,34 @@ sections = [ known_esi = [ "esi", ] -known_django = [ +known_django = [ #Lump relatively "django", + "django_redis", + "django_registration", ] skip_gitignore = true + +[tool.flake8] +exclude = [ + ".git", + "*migrations*", + ".tox", + "dist", + "htmlcov", +] +max-line-length = 119 +select = [ + "C", # pylint convention + "E", # pycodestyle error + "F", # pyflakes (flake8 base) + "W", # pycodestyle Warning + "B", # flake8-bugbear +] +ignore = [ + "E501", # Line too long, WIP across repo. +] + +[tool.djlint] +max_attribute_length = 119 +max_line_length = 119 +max_blank_lines = 1