Skip to content

Commit

Permalink
Use ruff for linting
Browse files Browse the repository at this point in the history
Use ruff instead of flake8+isort+pyupgrade+pygrep-hooks. This change
configures ruff to apply all the same rules that these tools apply.

I've omitted E501 for now since there are a few violations.
  • Loading branch information
WhyNotHugo committed May 16, 2023
1 parent de7e19c commit 4e22af6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

22 changes: 5 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,18 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/doc8
rev: v1.1.1
hooks:
- id: doc8
- repo: https://github.com/asottile/pyupgrade
rev: v3.4.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.13.0
hooks:
- id: django-upgrade
args: [--target-version, "3.2"]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-mock-methods
- id: python-no-eval
- id: python-no-log-warn
- id: rst-backticks
- id: rst-directive-colons
- repo: https://github.com/pre-commit/mirrors-prettier
Expand All @@ -53,6 +36,11 @@ repos:
types: [file]
args:
- --fix
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.267'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Style
-----

The Django Debug Toolbar uses `black <https://github.com/psf/black>`__ to
format code and additionally uses flake8 and isort. The toolbar uses
format code and additionally uses ruff. The toolbar uses
`pre-commit <https://pre-commit.com>`__ to automatically apply our style
guidelines when a commit is made. Set up pre-commit before committing with::

Expand Down
24 changes: 21 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ packages = ["debug_toolbar"]
[tool.hatch.version]
path = "debug_toolbar/__init__.py"

[tool.isort]
combine_as_imports = true
profile = "black"
[tool.ruff.isort]
combine-as-imports = true

[tool.coverage.html]
skip_covered = true
Expand All @@ -75,3 +74,22 @@ source = ["src", ".tox/*/site-packages"]
# Update coverage badge link in README.rst when fail_under changes
fail_under = 94
show_missing = true

[tool.ruff]
select = [
# flake8/Pyflakes
"F",
# flake8/pycodestyle
"E",
"W",
# isort
"I",
# pyupgrade
"UP",
# pygrep-hooks
"PGH",
]
ignore = [
"E501",
]
target-version = "py38"
2 changes: 0 additions & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ Jinja2
# Testing

coverage[toml]
flake8
html5lib
isort
selenium
tox
black
Expand Down

0 comments on commit 4e22af6

Please sign in to comment.