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 c8defa7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 32 deletions.
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

27 changes: 5 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,15 @@ 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
rev: v3.0.0-alpha.9-for-vscode
hooks:
Expand Down Expand Up @@ -67,3 +45,8 @@ repos:
rev: v0.12.2
hooks:
- id: validate-pyproject
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.267'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
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"
3 changes: 1 addition & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ Jinja2
# Testing

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

0 comments on commit c8defa7

Please sign in to comment.