Skip to content

Commit fee12ee

Browse files
authored
chore: enable more Ruff checks (#126)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 5acfe86 commit fee12ee

File tree

8 files changed

+33
-31
lines changed

8 files changed

+33
-31
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ repos:
5050
additional_dependencies:
5151
- tomli
5252
- pathspec
53-
- pytest
53+
- pytest<9 # pytest 9 requires Python 3.10+
5454
- validate-pyproject
5555
- uv
5656

pyproject.toml

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -105,35 +105,21 @@ disallow_incomplete_defs = true
105105

106106

107107
[tool.ruff.lint]
108-
extend-select = [
109-
"B", # flake8-bugbear
110-
"I", # isort
111-
"ARG", # flake8-unused-arguments
112-
"C4", # flake8-comprehensions
113-
"EM", # flake8-errmsg
114-
"ICN", # flake8-import-conventions
115-
"ISC", # flake8-implicit-str-concat
116-
"G", # flake8-logging-format
117-
"PGH", # pygrep-hooks
118-
"PIE", # flake8-pie
119-
"PL", # pylint
120-
"PT", # flake8-pytest-style
121-
"PTH", # flake8-use-pathlib
122-
"RET", # flake8-return
123-
"RUF", # Ruff-specific
124-
"SIM", # flake8-simplify
125-
"UP", # pyupgrade
126-
"YTT", # flake8-2020
127-
"EXE", # flake8-executable
128-
]
108+
select = ["ALL"]
129109
ignore = [
130110
"PLR09", # Design related pylint codes
131111
"E501", # Line too long
132-
"ISC001", # Conflicts with formatter
112+
"COM", # Trailing commas teach the formatter
113+
"S", # Security related checks go too far (no assert, for example)
114+
"D", # Too many docstring warnings
115+
"T20", # Print is intentional here
133116
]
134117
flake8-unused-arguments.ignore-variadic-names = true
135118
isort.required-imports = ["from __future__ import annotations"]
136119

120+
[tool.ruff.lint.per-file-ignores]
121+
"tests/*" = ["ANN201", "INP"]
122+
137123

138124
[tool.pylint]
139125
py-version = "3.9"

src/check_sdist/__main__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
import argparse
44
import contextlib
5-
from collections.abc import Sequence
65
from pathlib import Path
7-
from typing import Literal
6+
from typing import TYPE_CHECKING, Literal
87

98
import pathspec
109

@@ -16,6 +15,9 @@
1615
from .resources import resources
1716
from .sdist import get_uv, sdist_files
1817

18+
if TYPE_CHECKING:
19+
from collections.abc import Sequence
20+
1921

2022
def select_installer(
2123
installer: Literal["pip", "uv", "uv|pip"],

src/check_sdist/git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55

66

7-
def git_files(source_dir: Path, recurse_submodules: bool = True) -> frozenset[str]:
7+
def git_files(source_dir: Path, *, recurse_submodules: bool = True) -> frozenset[str]:
88
"""Return the files that are tracked by git in the source directory."""
99

1010
cmd = ["git", "ls-files", "--cached"]

src/check_sdist/inject.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
import contextlib
44
import sys
5-
from collections.abc import Generator, Sequence
6-
from pathlib import Path
5+
from typing import TYPE_CHECKING
76

87
from .resources import resources
98

9+
if TYPE_CHECKING:
10+
from collections.abc import Generator, Sequence
11+
from pathlib import Path
12+
1013
__all__ = ["inject_files", "inject_junk_files"]
1114

1215

tests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from check_sdist.__main__ import main
77

88

9-
def test_version(capsys):
9+
def test_version(capsys: pytest.CaptureFixture[str]):
1010
with pytest.raises(SystemExit):
1111
main(["--version"])
1212

tests/test_downstream.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import subprocess
44
import sys
55
from pathlib import Path
6+
from typing import Literal
67

78
import pytest
89

@@ -28,7 +29,14 @@
2829
@pytest.mark.parametrize(
2930
("repo", "ref", "fail"), [(x["repo"], x["ref"], x.get("fail", 0)) for x in packages]
3031
)
31-
def test_packages(repo, ref, fail, tmp_path, monkeypatch, installer):
32+
def test_packages(
33+
repo: str,
34+
ref: str,
35+
fail: int,
36+
tmp_path: Path,
37+
monkeypatch: pytest.MonkeyPatch,
38+
installer: Literal["uv", "pip"],
39+
):
3240
if repo.endswith("scikit-build") and sys.platform.startswith("win32"):
3341
pytest.skip(reason="Path too long on Windows (0.18)")
3442

tests/test_inject.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
from __future__ import annotations
22

3-
from pathlib import Path
3+
from typing import TYPE_CHECKING
44

55
from check_sdist.inject import inject_files, inject_junk_files
66

7+
if TYPE_CHECKING:
8+
from pathlib import Path
9+
710

811
def test_inject_files(tmp_path: Path):
912
with inject_files(tmp_path, ["a", "b", "c/", "d/e", "f/g/"]):

0 commit comments

Comments
 (0)