Merge branch 'ruff' into 'v5.x'

Linting and Formatting changes for 5.x

See merge request allianceauth/allianceauth!1644
This commit is contained in:
Ariel Rin 2024-09-13 10:50:16 +00:00
commit 27cf74f507
3 changed files with 80 additions and 11 deletions

1
.gitignore vendored
View File

@ -71,6 +71,7 @@ celerybeat-schedule
#other
.flake8
.ruff_cache
.pylintrc
Makefile
alliance_auth.sqlite3

View File

@ -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

View File

@ -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