Skip to content

Commit 38c6680

Browse files
committed
Migrated to using Ruff for linting and formatting
1 parent 4f78a6f commit 38c6680

File tree

2 files changed

+25
-91
lines changed

2 files changed

+25
-91
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -45,53 +45,15 @@ repos:
4545
name: Formatting the pyproject.toml file
4646
additional_dependencies: ["tox>=4.9"]
4747

48-
# Automatic source code formatting
49-
- repo: https://github.com/psf/black
50-
rev: 24.3.0 # Released 2024-03-15
48+
# Format and lint using Ruff
49+
- repo: https://github.com/astral-sh/ruff-pre-commit
50+
rev: v0.6.9
5151
hooks:
52-
- id: black
53-
name: Formatting Python scripts according to Black
54-
args: [--safe, --quiet]
55-
56-
# Automatically sort imports
57-
- repo: https://github.com/PyCQA/isort
58-
rev: 5.13.2 # Released 2023-12-13
59-
hooks:
60-
- id: isort
61-
name: Tidying Python imports via Isort
62-
args: [
63-
#'-a', 'from __future__ import annotations', # 3.7-3.11
64-
"--rm",
65-
"from __future__ import absolute_import", # -3.0
66-
"--rm",
67-
"from __future__ import division", # -3.0
68-
"--rm",
69-
"from __future__ import generator_stop", # -3.7
70-
"--rm",
71-
"from __future__ import generators", # -2.3
72-
"--rm",
73-
"from __future__ import nested_scopes", # -2.2
74-
"--rm",
75-
"from __future__ import print_function", # -3.0
76-
"--rm",
77-
"from __future__ import unicode_literals", # -3.0
78-
"--rm",
79-
"from __future__ import with_statement", # -2.6
80-
]
81-
82-
# Linting
83-
- repo: https://github.com/PyCQA/flake8
84-
# Release history: https://flake8.pycqa.org/en/latest/release-notes/index.html
85-
rev: 7.0.0 # Released 2024-01-05
86-
hooks:
87-
- id: flake8
88-
name: Running Flake8 linter on Python files
89-
additional_dependencies: [
90-
# Added Flake8-pyproject plugin for .toml compatibility
91-
"Flake8-pyproject==1.2.3", # Released 2023-03-21
92-
# flake8-comprehensions URL: https://github.com/adamchainz/flake8-comprehensions
93-
"flake8-comprehensions==3.14.0", # Released 2023-07-10
94-
]
52+
- id: ruff
53+
name: Running Ruff linter
54+
args: ["--fix"]
55+
- id: ruff-format
56+
name: Running Ruff formatter
9557

9658
# Type checking
9759
- repo: https://github.com/pre-commit/mirrors-mypy

pyproject.toml

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -121,53 +121,25 @@ zip-safe = false
121121
[tool.setuptools.packages.find]
122122
where = ["src", "tests"]
123123

124-
[tool.isort]
125-
profile = "black"
126-
127-
[tool.flake8]
128-
# Flake8-pyproject allows TOML file settings to be read into Flake8
129-
# URL: https://pypi.org/project/Flake8-pyproject/
130-
select = [
124+
[tool.ruff]
125+
line-length = 88
126+
lint.extend-ignore = ["E203", "E266", "E501", "E731", "E741"]
127+
lint.select = [
131128
"C4",
132-
"E401",
133-
"E711",
134-
"E712",
135-
"E713",
136-
"E714",
137-
"E721",
138-
"E722",
139-
"E901",
140-
"F401",
141-
"F402",
142-
"F403",
143-
"F405",
144-
"F541",
145-
"F631",
146-
"F632",
147-
"F633",
148-
"F811",
149-
"F812",
150-
"F821",
151-
"F822",
152-
"F841",
153-
"F901",
154-
"W191",
155-
"W291",
156-
"W292",
157-
"W293",
158-
"W602",
159-
"W603",
160-
"W604",
161-
"W605",
162-
"W606",
163-
]
164-
ignore = [
165-
"E203",
166-
"E266",
167-
"E501",
168-
"W503",
129+
"E4", "E7", "E9",
130+
"F",
131+
"W6",
169132
]
170-
max-line-length = "88"
133+
fix = true
134+
135+
[tool.ruff.lint.isort]
136+
known-first-party = []
137+
combine-as-imports = true
138+
139+
[tool.ruff.format]
140+
quote-style="double"
141+
indent-style="space"
142+
line-ending="auto"
171143

172144
[tool.pyproject-fmt]
173145
inputs = "pyproject.toml"

0 commit comments

Comments
 (0)