Skip to content

Commit 0f22268

Browse files
authored
Lint: Add Ruff (#3429)
1 parent 971a49b commit 0f22268

File tree

11 files changed

+40
-25
lines changed

11 files changed

+40
-25
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ contents.rst @AA-Turner
2020
.codespell/ @CAM-Gerlach @hugovk
2121
.codespellrc @CAM-Gerlach @hugovk
2222
.pre-commit-config.yaml @CAM-Gerlach @hugovk
23+
.ruff.toml @AA-Turner @CAM-Gerlach @hugovk
2324
check-peps.py @AA-Turner @CAM-Gerlach @hugovk
2425

2526
# Git infrastructure

.pre-commit-config.yaml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ repos:
4242
- id: check-yaml
4343
name: "Check YAML"
4444

45+
- repo: https://github.com/astral-sh/ruff-pre-commit
46+
rev: v0.0.287
47+
hooks:
48+
- id: ruff
49+
name: "Lint with Ruff"
50+
args:
51+
- '--exit-non-zero-on-fix'
52+
- '--diff'
53+
- '--format=github'
54+
files: '^pep_sphinx_extensions/tests/'
55+
4556
- repo: https://github.com/psf/black
4657
rev: 23.7.0
4758
hooks:
@@ -52,14 +63,6 @@ repos:
5263
- '--target-version=py310'
5364
files: 'pep_sphinx_extensions/tests/.*'
5465

55-
- repo: https://github.com/PyCQA/isort
56-
rev: 5.12.0
57-
hooks:
58-
- id: isort
59-
name: "Sort imports with isort"
60-
args: ['--profile=black', '--atomic']
61-
files: 'pep_sphinx_extensions/tests/.*'
62-
6366
- repo: https://github.com/tox-dev/tox-ini-fmt
6467
rev: 1.3.1
6568
hooks:

.ruff.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ignore = [
2+
"E501", # Line too long
3+
]
4+
5+
select = [
6+
"E", # pycodestyle errors
7+
"F", # pyflakes
8+
"I", # isort
9+
"PT", # flake8-pytest-style
10+
"W", # pycodestyle warnings
11+
]
12+
13+
show-source = true
14+
15+
target-version = "py39"

pep_sphinx_extensions/tests/pep_lint/test_date.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def test_date_checker_too_early(date_str: str):
9393
[
9494
# the future
9595
"31-Dec-2999",
96-
"01-Jan-2100",
96+
"01-Jan-2042",
9797
"01-Jan-2100",
9898
(dt.datetime.now() + dt.timedelta(days=15)).strftime("%d-%b-%Y"),
9999
(dt.datetime.now() + dt.timedelta(days=100)).strftime("%d-%b-%Y"),

pep_sphinx_extensions/tests/pep_lint/test_email.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def test_validate_delegate(line: str):
149149
(r"Cardinal Ximénez <Cardinal\Ximenez@spanish.inquisition>", {"valid email"}),
150150
("Cardinal Ximénez <[Cardinal.Ximenez]@spanish.inquisition>", {"valid email"}),
151151
('Cardinal Ximénez <"Cardinal"Ximenez"@spanish.inquisition>', {"valid email"}),
152-
("Cardinal Ximénez <Cardinal;Ximenez@spanish.inquisition>", {"valid email"}),
152+
("Cardinal Ximenez <Cardinal;Ximenez@spanish.inquisition>", {"valid email"}),
153153
("Cardinal Ximénez <Cardinal£Ximénez@spanish.inquisition>", {"valid email"}),
154154
("Cardinal Ximénez <Cardinal§Ximenez@spanish.inquisition>", {"valid email"}),
155155
# ... entries must contain a valid email address (domain)

pep_sphinx_extensions/tests/pep_lint/test_headers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def test_validate_type_invalid(line: str):
196196
# duplicates
197197
("Governance, Governance", {"duplicates"}),
198198
("Release, Release", {"duplicates"}),
199-
("Release, Release", {"duplicates"}),
199+
("Packaging, Packaging", {"duplicates"}),
200200
("Spam, Spam", {"duplicates", "valid"}),
201201
("lobster, lobster", {"duplicates", "capitalisation", "valid"}),
202202
("governance, governance", {"duplicates", "capitalisation"}),

pep_sphinx_extensions/tests/pep_lint/test_post_url.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ def test_validate_resolution_valid(line: str):
108108
"https://mail.python.org/archives/list/list-name@python.org/thread/abcXYZ123/#anchor",
109109
"https://mail.python.org/archives/list/list-name@python.org/message/#abcXYZ123",
110110
"https://mail.python.org/archives/list/list-name@python.org/message/#abcXYZ123/",
111-
"https://mail.python.org/archives/list/list-name@python.org/message/abcXYZ123/anchor/",
112-
"https://mail.python.org/archives/list/list-name@python.org/message/abcXYZ123/anchor/",
113111
"https://mail.python.org/archives/list/list-name@python.org/spam/abcXYZ123",
114112
"https://mail.python.org/archives/list/list-name@python.org/spam/abcXYZ123/",
115113
],
@@ -233,8 +231,6 @@ def test_thread_checker_valid_allow_message(thread_url: str):
233231
"https://mail.python.org/archives/list/list-name@python.org/thread/abcXYZ123/#anchor",
234232
"https://mail.python.org/archives/list/list-name@python.org/message/#abcXYZ123",
235233
"https://mail.python.org/archives/list/list-name@python.org/message/#abcXYZ123/",
236-
"https://mail.python.org/archives/list/list-name@python.org/message/abcXYZ123/anchor/",
237-
"https://mail.python.org/archives/list/list-name@python.org/message/abcXYZ123/anchor/",
238234
"https://mail.python.org/archives/list/list-name@python.org/spam/abcXYZ123",
239235
"https://mail.python.org/archives/list/list-name@python.org/spam/abcXYZ123/",
240236
],

pep_sphinx_extensions/tests/pep_processor/transform/test_pep_headers.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
@pytest.mark.parametrize(
21-
"test_input, expected",
21+
("test_input", "expected"),
2222
[
2323
("my-mailing-list@example.com", "my-mailing-list@example.com"),
2424
("python-tulip@googlegroups.com", "https://groups.google.com/g/python-tulip"),
@@ -37,7 +37,7 @@ def test_generate_list_url(test_input, expected):
3737

3838

3939
@pytest.mark.parametrize(
40-
"test_input, expected",
40+
("test_input", "expected"),
4141
[
4242
(
4343
"https://mail.python.org/pipermail/python-3000/2006-November/004190.html",
@@ -72,7 +72,7 @@ def test_process_pretty_url(test_input, expected):
7272

7373

7474
@pytest.mark.parametrize(
75-
"test_input, expected",
75+
("test_input", "expected"),
7676
[
7777
(
7878
"https://example.com/",
@@ -94,7 +94,7 @@ def test_process_pretty_url_invalid(test_input, expected):
9494

9595

9696
@pytest.mark.parametrize(
97-
"test_input, expected",
97+
("test_input", "expected"),
9898
[
9999
(
100100
"https://mail.python.org/pipermail/python-3000/2006-November/004190.html",
@@ -129,7 +129,7 @@ def test_make_link_pretty(test_input, expected):
129129

130130

131131
@pytest.mark.parametrize(
132-
"test_input, expected",
132+
("test_input", "expected"),
133133
[
134134
(STATUS_ACCEPTED, "Normative proposal accepted for implementation"),
135135
(STATUS_ACTIVE, "Currently valid informational guidance, or an in-use process"),
@@ -155,7 +155,7 @@ def test_abbreviate_status_unknown():
155155

156156

157157
@pytest.mark.parametrize(
158-
"test_input, expected",
158+
("test_input", "expected"),
159159
[
160160
(
161161
TYPE_INFO,

pep_sphinx_extensions/tests/pep_processor/transform/test_pep_zero.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
@pytest.mark.parametrize(
8-
"test_input, expected",
8+
("test_input", "expected"),
99
[
1010
(
1111
nodes.reference(

pep_sphinx_extensions/tests/pep_zero_generator/test_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_pep_details(monkeypatch):
5252

5353

5454
@pytest.mark.parametrize(
55-
"test_input, expected",
55+
("test_input", "expected"),
5656
[
5757
(
5858
"First Last <user@example.com>",
@@ -88,7 +88,7 @@ def test_parse_authors_invalid():
8888

8989

9090
@pytest.mark.parametrize(
91-
"test_type, test_status, expected",
91+
("test_type", "test_status", "expected"),
9292
[
9393
(TYPE_INFO, STATUS_DRAFT, ":abbr:`I (Informational, Draft)`"),
9494
(TYPE_INFO, STATUS_ACTIVE, ":abbr:`IA (Informational, Active)`"),

0 commit comments

Comments
 (0)