diff --git a/.gitignore b/.gitignore index 80cc8d9a..16477aa5 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ __pycache__/ .fleet .DS_Store +.ruff_cache diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3ad01611..b82cbf6a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ default_language_version: python: python3.8 repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 + rev: v4.4.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -14,23 +14,20 @@ repos: args: ['--unsafe'] - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/psf/black - rev: 22.3.0 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 23.9.1 hooks: - id: black - - repo: https://github.com/pycqa/isort - # isort config is in setup.cfg - rev: 5.12.0 + - repo: https://github.com/adamchainz/blacken-docs + rev: 1.16.0 hooks: - - id: isort - - repo: https://github.com/pycqa/flake8 - # flake8 config is in setup.cfg - rev: 4.0.1 + - id: blacken-docs + additional_dependencies: [black==23.9.1] + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: 'v0.0.291' hooks: - - id: flake8 - additional_dependencies: - - flake8-bugbear - - flake8-comprehensions + - id: ruff + args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/pre-commit/mirrors-prettier rev: 'v2.7.1' hooks: @@ -51,8 +48,3 @@ repos: - typescript@3.9.9 - '@typescript-eslint/eslint-plugin@1.13.0' - '@typescript-eslint/parser@1.13.0' - - repo: https://github.com/asottile/blacken-docs - rev: v1.12.1 - hooks: - - id: blacken-docs - additional_dependencies: [black==22.3.0] diff --git a/pyproject.toml b/pyproject.toml index d69c7b14..be24952b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,6 @@ classifiers = [ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -44,7 +43,7 @@ testing = [ "freezegun==1.1.0", "django-rq>=2.5,<3.0", "google-cloud-translate>=3.0.0", - "pre-commit>=2.21.0,<3.0" + "pre-commit>=3.4,<4" ] documentation = [ "mkdocs==1.4.3", diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 00000000..2b37ede4 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,34 @@ +target-version = "py38" + +exclude = ["dist","build","venv",".venv",".tox",".git", "__pycache__", "node_modules", "LC_MESSAGES", "locale"] + +select = [ + "B", # flake8-bugbear + "BLE", # flake8-blind-except + "C4", # flake8-comprehensions + "DJ", # flake8-django + "E", # pycodestyle errors + "F", # pyflakes + "I", # isort + "PGH", # pygrep-hooks + "RUF100", # unused noqa + "S", # flake8-bandit + "T20", # flake8-print + "UP", # pyupgrade + "W", # pycodestyle warnings + "YTT", # flake8-2020 +] + +fixable = ["C4", "E", "F", "I", "UP"] + +# E501: Line too long +ignore = ["E501","B028"] + +[per-file-ignores] +"tests/**.py" = ["DJ008"] +"**/report_nightly_build_failure.py" = ["T201"] + +[isort] +known-first-party = ["wagtail_localize"] +lines-between-types = 1 +lines-after-imports = 2 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 1a78d709..00000000 --- a/setup.cfg +++ /dev/null @@ -1,12 +0,0 @@ -[flake8] -max-line-length=88 -exclude=migrations,dist,build,venv,node_modules,.tox,venv,.venv,.git -extend-ignore = E203 - -[isort] -known_first_party=wagtail_localize -skip=migrations,.git,__pycache__,LC_MESSAGES,locale,build,dist,.github,.tox,venv,.venv,node_modules -blocked_extensions=rst,html,js,svg,txt,css,scss,png,snap,tsx,sh -lines_between_types=1 -lines_after_imports=2 -profile=black diff --git a/tox.ini b/tox.ini index 31a28d58..9805e51f 100644 --- a/tox.ini +++ b/tox.ini @@ -19,12 +19,6 @@ DATABASE = postgres: postgres sqlite: sqlite -[flake8] -# E501: Line too long -# W503: line break before binary operator (superseded by W504 line break after binary operator) -ignore = E501,W503 -exclude = migrations,node_modules - [testenv] pass_env = FORCE_COLOR