Skip to content

Commit 35a1b61

Browse files
authored
Merge branch 'master' into pyproject
2 parents 2a1dbb5 + 779da2b commit 35a1b61

File tree

7 files changed

+31
-54
lines changed

7 files changed

+31
-54
lines changed

.github/workflows/lint.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v4
1111
- name: Set up Python
12-
uses: actions/setup-python@v4
12+
uses: actions/setup-python@v5
1313
with:
1414
python-version: "3.10"
1515
- name: Install Ruff
1616
run: |
17-
python -m pip install ruff>=0.5
18-
- name: Format check (Ruff)
17+
python -m pip install ruff>=0.6
18+
- name: Lint using Ruff
1919
run: |
2020
ruff format --check
21+
ruff check

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
fetch-depth: 0
1717

1818
- name: Set up Python
19-
uses: actions/setup-python@v4
19+
uses: actions/setup-python@v5
2020
with:
2121
python-version: '3.12'
2222

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- uses: actions/checkout@v4
3030

3131
- name: Set up Python ${{ matrix.python-version }}
32-
uses: actions/setup-python@v4
32+
uses: actions/setup-python@v5
3333
with:
3434
python-version: ${{ matrix.python-version }}
3535

.pre-commit-config.yaml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.5.7
3+
rev: v0.6.0
44
hooks:
5+
- id: ruff
6+
args: [ --fix ]
57
- id: ruff-format
68
- repo: https://github.com/pre-commit/pre-commit-hooks
79
rev: v4.6.0
@@ -14,16 +16,6 @@ repos:
1416
- id: check-yaml
1517
- id: mixed-line-ending
1618
args: ['--fix=lf']
17-
- repo: https://github.com/PyCQA/isort
18-
rev: 5.13.2
19-
hooks:
20-
- id: isort
21-
exclude: ^(oauth2_provider/migrations/|tests/migrations/)
22-
- repo: https://github.com/PyCQA/flake8
23-
rev: 7.1.1
24-
hooks:
25-
- id: flake8
26-
exclude: ^(oauth2_provider/migrations/|tests/migrations/)
2719
- repo: https://github.com/sphinx-contrib/sphinx-lint
2820
rev: v0.9.1
2921
hooks:

docs/contributing.rst

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,26 @@ add a comment stating you're working on it.
2727
Code Style
2828
==========
2929

30-
The project uses `flake8 <https://flake8.pycqa.org/en/latest/>`_ for linting,
31-
`black <https://black.readthedocs.io/en/stable/>`_ for formatting the code,
32-
`isort <https://pycqa.github.io/isort/>`_ for formatting and sorting imports,
33-
and `pre-commit <https://pre-commit.com/>`_ for checking/fixing commits for
34-
correctness before they are made.
30+
The project uses `ruff <https://docs.astral.sh/ruff/>`_ for linting, formatting the code and sorting imports,
31+
and `pre-commit <https://pre-commit.com/>`_ for checking/fixing commits for correctness before they are made.
3532

3633
You will need to install ``pre-commit`` yourself, and then ``pre-commit`` will
37-
take care of installing ``flake8``, ``black`` and ``isort``.
34+
take care of installing ``ruff``.
3835

3936
After cloning your repository, go into it and run::
4037

4138
pre-commit install
4239

4340
to install the hooks. On the next commit that you make, ``pre-commit`` will
4441
download and install the necessary hooks (a one off task). If anything in the
45-
commit would fail the hooks, the commit will be abandoned. For ``black`` and
46-
``isort``, any necessary changes will be made automatically, but not staged.
42+
commit would fail the hooks, the commit will be abandoned. For ``ruff``, any
43+
necessary changes will be made automatically, but not staged.
4744
Review the changes, and then re-stage and commit again.
4845

4946
Using ``pre-commit`` ensures that code that would fail in QA does not make it
5047
into a commit in the first place, and will save you time in the long run. You
5148
can also (largely) stop worrying about code style, although you should always
52-
check how the code looks after ``black`` has formatted it, and think if there
49+
check how the code looks after ``ruff`` has formatted it, and think if there
5350
is a better way to structure the code so that it is more readable.
5451

5552
Documentation
@@ -265,7 +262,7 @@ add a comment. If you think a function is not trivial, add a docstrings.
265262

266263
To see if your code formatting will pass muster use::
267264

268-
tox -e flake8
265+
tox -e lint
269266

270267
The contents of this page are heavily based on the docs from `django-admin2 <https://github.com/twoscoops/django-admin2>`_
271268

pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,11 @@ ignore-words-list = 'assertIn'
5656

5757
[tool.ruff]
5858
line-length = 110
59-
exclude = [".tox", "oauth2_provider/migrations/", "tests/migrations/", "manage.py"]
59+
exclude = [".tox", "build/", "dist/", "docs/", "oauth2_provider/migrations/", "tests/migrations/", "manage.py"]
60+
61+
[tool.ruff.lint]
62+
select = ["E", "F", "I", "Q", "W"]
63+
64+
[tool.ruff.lint.isort]
65+
lines-after-imports = 2
66+
known-first-party = ["oauth2_provider"]

tox.ini

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[tox]
22
envlist =
3-
flake8,
43
migrations,
54
migrate_swapped,
65
docs,
6+
lint,
77
sphinxlint,
88
py{38,39,310,311,312}-dj42,
99
py{310,311,312}-dj50,
@@ -12,7 +12,7 @@ envlist =
1212

1313
[gh-actions]
1414
python =
15-
3.8: py38, docs, flake8, migrations, migrate_swapped, sphinxlint
15+
3.8: py38, docs, lint, migrations, migrate_swapped, sphinxlint
1616
3.9: py39
1717
3.10: py310
1818
3.11: py311
@@ -92,14 +92,13 @@ deps =
9292
jwcrypto
9393
django
9494

95-
[testenv:flake8]
95+
[testenv:lint]
9696
basepython = python3.8
97+
deps = ruff>=0.6
9798
skip_install = True
98-
commands = flake8 {toxinidir}
99-
deps =
100-
flake8
101-
flake8-isort
102-
flake8-quotes
99+
commands =
100+
ruff format --check
101+
ruff check
103102

104103
[testenv:migrations]
105104
setenv =
@@ -132,22 +131,3 @@ omit = */migrations/*
132131

133132
[coverage:report]
134133
show_missing = True
135-
136-
[flake8]
137-
max-line-length = 110
138-
exclude = docs/, oauth2_provider/migrations/, tests/migrations/, .tox/, build/, dist/
139-
application-import-names = oauth2_provider
140-
inline-quotes = double
141-
extend-ignore = E203, W503
142-
143-
[isort]
144-
default_section = THIRDPARTY
145-
known_first_party = oauth2_provider
146-
line_length = 110
147-
lines_after_imports = 2
148-
multi_line_output = 3
149-
include_trailing_comma = True
150-
force_grid_wrap = 0
151-
use_parentheses = True
152-
ensure_newline_before_comments = True
153-
skip = oauth2_provider/migrations/, .tox/, tests/migrations/

0 commit comments

Comments
 (0)