Skip to content

Commit 0e38569

Browse files
committed
🧪 Configure pre-commit to format Python w/ Ruff
1 parent 234a2d3 commit 0e38569

File tree

3 files changed

+55
-6
lines changed

3 files changed

+55
-6
lines changed

.isort.cfg

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ known_first_party = pylibsshext
99
# known_future_library = future,pies
1010
# known_standard_library = std,std2
1111
known_testing = pytest,unittest,_service_utils
12-
known_cython = libc,cpython,Cython
13-
# known_third_party = Cython
12+
known_frameworks = libc,cpython,Cython
1413
# length_sort = 1
1514
# Should be: 80 - 1
1615
line_length = 79
1716
lines_after_imports = 2
1817
# https://github.com/timothycrosley/isort#multi-line-output-modes
1918
multi_line_output = 5
2019
no_lines_before = LOCALFOLDER
21-
sections=FUTURE,STDLIB,CYTHON,TESTING,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
20+
sections=FUTURE,STDLIB,FRAMEWORKS,TESTING,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
2221
# skip=file3.py,file4.py
2322
use_parentheses = true
2423
verbose = true

.pre-commit-config.yaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,33 @@ ci:
44
autoupdate_schedule: quarterly
55

66
repos:
7+
- repo: https://github.com/astral-sh/ruff-pre-commit.git
8+
rev: v0.13.3
9+
hooks:
10+
- id: ruff-format # Cython imports are handled by `isort`
11+
alias: ruff-format-first-pass
12+
name: ruff-format (first pass)
13+
714
- repo: https://github.com/asottile/add-trailing-comma.git
815
rev: v3.2.0
916
hooks:
1017
- id: add-trailing-comma
1118

19+
- repo: https://github.com/astral-sh/ruff-pre-commit.git
20+
rev: v0.13.3
21+
hooks:
22+
- id: ruff-format # Cython imports are handled by `isort`
23+
alias: ruff-format-second-pass
24+
name: ruff-format (second pass)
25+
1226
- repo: https://github.com/PyCQA/isort.git
1327
rev: 6.1.0
1428
hooks:
1529
- id: isort
1630
args:
1731
- --honor-noqa
18-
files: >-
19-
^.*\.p(xd|y|yx)$
20-
types: [file]
32+
types_or:
33+
- cython # Python is handled by Ruff
2134

2235
- repo: https://github.com/Lucas-C/pre-commit-hooks.git
2336
rev: v1.5.5

.ruff.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
line-length = 79 # Accessibility-friendly
2+
3+
[format]
4+
quote-style = "single"
5+
6+
[lint.isort]
7+
combine-as-imports = true
8+
force-wrap-aliases = true
9+
lines-after-imports = 2
10+
section-order = [
11+
"future",
12+
"standard-library",
13+
"testing",
14+
"frameworks",
15+
"platforms",
16+
"third-party",
17+
"first-party",
18+
"local-folder",
19+
]
20+
21+
[lint.isort.sections]
22+
frameworks = [
23+
"libc",
24+
"cpython",
25+
"Cython",
26+
]
27+
platforms = [
28+
# "awx_plugins.interfaces",
29+
]
30+
testing = [
31+
"hypothesis",
32+
"pytest",
33+
"pytest_mock",
34+
"pytest_subtests",
35+
"unittest",
36+
"_service_utils",
37+
]

0 commit comments

Comments
 (0)