Skip to content

Commit

Permalink
Lint: Add Ruff (#3429)
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner authored Sep 9, 2023
1 parent 971a49b commit 0f22268
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 25 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ contents.rst @AA-Turner
.codespell/ @CAM-Gerlach @hugovk
.codespellrc @CAM-Gerlach @hugovk
.pre-commit-config.yaml @CAM-Gerlach @hugovk
.ruff.toml @AA-Turner @CAM-Gerlach @hugovk
check-peps.py @AA-Turner @CAM-Gerlach @hugovk

# Git infrastructure
Expand Down
19 changes: 11 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ repos:
- id: check-yaml
name: "Check YAML"

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.287
hooks:
- id: ruff
name: "Lint with Ruff"
args:
- '--exit-non-zero-on-fix'
- '--diff'
- '--format=github'
files: '^pep_sphinx_extensions/tests/'

- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
Expand All @@ -52,14 +63,6 @@ repos:
- '--target-version=py310'
files: 'pep_sphinx_extensions/tests/.*'

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
name: "Sort imports with isort"
args: ['--profile=black', '--atomic']
files: 'pep_sphinx_extensions/tests/.*'

- repo: https://github.com/tox-dev/tox-ini-fmt
rev: 1.3.1
hooks:
Expand Down
15 changes: 15 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ignore = [
"E501", # Line too long
]

select = [
"E", # pycodestyle errors
"F", # pyflakes
"I", # isort
"PT", # flake8-pytest-style
"W", # pycodestyle warnings
]

show-source = true

target-version = "py39"
2 changes: 1 addition & 1 deletion pep_sphinx_extensions/tests/pep_lint/test_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_date_checker_too_early(date_str: str):
[
# the future
"31-Dec-2999",
"01-Jan-2100",
"01-Jan-2042",
"01-Jan-2100",
(dt.datetime.now() + dt.timedelta(days=15)).strftime("%d-%b-%Y"),
(dt.datetime.now() + dt.timedelta(days=100)).strftime("%d-%b-%Y"),
Expand Down
2 changes: 1 addition & 1 deletion pep_sphinx_extensions/tests/pep_lint/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_validate_delegate(line: str):
(r"Cardinal Ximénez <Cardinal\Ximenez@spanish.inquisition>", {"valid email"}),
("Cardinal Ximénez <[Cardinal.Ximenez]@spanish.inquisition>", {"valid email"}),
('Cardinal Ximénez <"Cardinal"Ximenez"@spanish.inquisition>', {"valid email"}),
("Cardinal Ximénez <Cardinal;Ximenez@spanish.inquisition>", {"valid email"}),
("Cardinal Ximenez <Cardinal;Ximenez@spanish.inquisition>", {"valid email"}),
("Cardinal Ximénez <Cardinal£Ximénez@spanish.inquisition>", {"valid email"}),
("Cardinal Ximénez <Cardinal§Ximenez@spanish.inquisition>", {"valid email"}),
# ... entries must contain a valid email address (domain)
Expand Down
2 changes: 1 addition & 1 deletion pep_sphinx_extensions/tests/pep_lint/test_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def test_validate_type_invalid(line: str):
# duplicates
("Governance, Governance", {"duplicates"}),
("Release, Release", {"duplicates"}),
("Release, Release", {"duplicates"}),
("Packaging, Packaging", {"duplicates"}),
("Spam, Spam", {"duplicates", "valid"}),
("lobster, lobster", {"duplicates", "capitalisation", "valid"}),
("governance, governance", {"duplicates", "capitalisation"}),
Expand Down
4 changes: 0 additions & 4 deletions pep_sphinx_extensions/tests/pep_lint/test_post_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ def test_validate_resolution_valid(line: str):
"https://mail.python.org/archives/list/list-name@python.org/thread/abcXYZ123/#anchor",
"https://mail.python.org/archives/list/list-name@python.org/message/#abcXYZ123",
"https://mail.python.org/archives/list/list-name@python.org/message/#abcXYZ123/",
"https://mail.python.org/archives/list/list-name@python.org/message/abcXYZ123/anchor/",
"https://mail.python.org/archives/list/list-name@python.org/message/abcXYZ123/anchor/",
"https://mail.python.org/archives/list/list-name@python.org/spam/abcXYZ123",
"https://mail.python.org/archives/list/list-name@python.org/spam/abcXYZ123/",
],
Expand Down Expand Up @@ -233,8 +231,6 @@ def test_thread_checker_valid_allow_message(thread_url: str):
"https://mail.python.org/archives/list/list-name@python.org/thread/abcXYZ123/#anchor",
"https://mail.python.org/archives/list/list-name@python.org/message/#abcXYZ123",
"https://mail.python.org/archives/list/list-name@python.org/message/#abcXYZ123/",
"https://mail.python.org/archives/list/list-name@python.org/message/abcXYZ123/anchor/",
"https://mail.python.org/archives/list/list-name@python.org/message/abcXYZ123/anchor/",
"https://mail.python.org/archives/list/list-name@python.org/spam/abcXYZ123",
"https://mail.python.org/archives/list/list-name@python.org/spam/abcXYZ123/",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


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


@pytest.mark.parametrize(
"test_input, expected",
("test_input", "expected"),
[
(
"https://mail.python.org/pipermail/python-3000/2006-November/004190.html",
Expand Down Expand Up @@ -72,7 +72,7 @@ def test_process_pretty_url(test_input, expected):


@pytest.mark.parametrize(
"test_input, expected",
("test_input", "expected"),
[
(
"https://example.com/",
Expand All @@ -94,7 +94,7 @@ def test_process_pretty_url_invalid(test_input, expected):


@pytest.mark.parametrize(
"test_input, expected",
("test_input", "expected"),
[
(
"https://mail.python.org/pipermail/python-3000/2006-November/004190.html",
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_make_link_pretty(test_input, expected):


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


@pytest.mark.parametrize(
"test_input, expected",
("test_input", "expected"),
[
(
TYPE_INFO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


@pytest.mark.parametrize(
"test_input, expected",
("test_input", "expected"),
[
(
nodes.reference(
Expand Down
4 changes: 2 additions & 2 deletions pep_sphinx_extensions/tests/pep_zero_generator/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_pep_details(monkeypatch):


@pytest.mark.parametrize(
"test_input, expected",
("test_input", "expected"),
[
(
"First Last <user@example.com>",
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_parse_authors_invalid():


@pytest.mark.parametrize(
"test_type, test_status, expected",
("test_type", "test_status", "expected"),
[
(TYPE_INFO, STATUS_DRAFT, ":abbr:`I (Informational, Draft)`"),
(TYPE_INFO, STATUS_ACTIVE, ":abbr:`IA (Informational, Active)`"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_pep_zero_writer_emit_title():


@pytest.mark.parametrize(
"test_input, expected",
("test_input", "expected"),
[
(
"pep-9000.rst",
Expand Down

0 comments on commit 0f22268

Please sign in to comment.