Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ruff for linting #1781

Merged
merged 2 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

24 changes: 7 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,20 @@ 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
- id: file-contents-sorter
files: docs/spelling_wordlist.txt
- 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 +38,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 debug_toolbar/panels/sql/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def contrasting_color_generator():
"""

def rgb_to_hex(rgb):
return "#%02x%02x%02x" % tuple(rgb)
return "#{:02x}{:02x}{:02x}".format(*tuple(rgb))

triples = [
(1, 0, 0),
Expand Down
2 changes: 2 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Pending
-------

* Adjusted app directories system check to allow for nested template loaders.
* Switched from flake8, isort and pyupgrade to `ruff
<https://beta.ruff.rs/>`__.

4.1.0 (2023-05-15)
------------------
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
25 changes: 13 additions & 12 deletions docs/spelling_wordlist.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Hatchling
Hotwire
Jazzband
Makefile
Pympler
Roboto
Transifex
Werkzeug
async
backend
backends
backported
Expand All @@ -9,17 +18,13 @@ fallbacks
flamegraph
flatpages
frontend
Hatchling
Hotwire
htmx
inlining
isort
Jazzband
jinja
jQuery
jinja
jrestclient
js
Makefile
margins
memcache
memcached
Expand All @@ -36,22 +41,18 @@ psycopg
py
pyflame
pylibmc
Pympler
pyupgrade
querysets
refactoring
resizing
Roboto
spellchecking
spooler
stacktrace
stacktraces
startup
timeline
theming
timeline
tox
Transifex
unhashable
uWSGI
unhashable
validator
Werkzeug
async
26 changes: 22 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ packages = ["debug_toolbar"]
[tool.hatch.version]
path = "debug_toolbar/__init__.py"

[tool.isort]
combine_as_imports = true
profile = "black"

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

[tool.ruff.isort]
combine-as-imports = 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