Skip to content

Commit 4bf597c

Browse files
committed
replace isort with ruff
1 parent 3e0329d commit 4bf597c

File tree

5 files changed

+18
-28
lines changed

5 files changed

+18
-28
lines changed

.github/workflows/lint.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ jobs:
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

.pre-commit-config.yaml

Lines changed: 3 additions & 6 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,11 +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/)
2219
- repo: https://github.com/PyCQA/flake8
2320
rev: 7.1.1
2421
hooks:

docs/contributing.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,27 @@ Code Style
2828
==========
2929

3030
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,
31+
`ruff <https://docs.astral.sh/ruff/>`_ for formatting the code and sorting imports,
3332
and `pre-commit <https://pre-commit.com/>`_ for checking/fixing commits for
3433
correctness before they are made.
3534

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

3938
After cloning your repository, go into it and run::
4039

4140
pre-commit install
4241

4342
to install the hooks. On the next commit that you make, ``pre-commit`` will
4443
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.
44+
commit would fail the hooks, the commit will be abandoned. For ``ruff``, any
45+
necessary changes will be made automatically, but not staged.
4746
Review the changes, and then re-stage and commit again.
4847

4948
Using ``pre-commit`` ensures that code that would fail in QA does not make it
5049
into a commit in the first place, and will save you time in the long run. You
5150
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
51+
check how the code looks after ``ruff`` has formatted it, and think if there
5352
is a better way to structure the code so that it is more readable.
5453

5554
Documentation

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@ ignore-words-list = 'assertIn'
88
[tool.ruff]
99
line-length = 110
1010
exclude = [".tox", "oauth2_provider/migrations/", "tests/migrations/", "manage.py"]
11+
12+
[tool.ruff.lint]
13+
select = ["I", "Q"]
14+
15+
[tool.ruff.lint.isort]
16+
lines-after-imports = 2
17+
known-first-party = ["oauth2_provider"]

tox.ini

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ skip_install = True
9797
commands = flake8 {toxinidir}
9898
deps =
9999
flake8
100-
flake8-isort
101-
flake8-quotes
102100

103101
[testenv:migrations]
104102
setenv =
@@ -137,15 +135,3 @@ exclude = docs/, oauth2_provider/migrations/, tests/migrations/, .tox/, build/,
137135
application-import-names = oauth2_provider
138136
inline-quotes = double
139137
extend-ignore = E203, W503
140-
141-
[isort]
142-
default_section = THIRDPARTY
143-
known_first_party = oauth2_provider
144-
line_length = 110
145-
lines_after_imports = 2
146-
multi_line_output = 3
147-
include_trailing_comma = True
148-
force_grid_wrap = 0
149-
use_parentheses = True
150-
ensure_newline_before_comments = True
151-
skip = oauth2_provider/migrations/, .tox/, tests/migrations/

0 commit comments

Comments
 (0)