Skip to content

Commit a8df53e

Browse files
committed
Enable the rest of the ruff rulesets we care about
1 parent 5f5255a commit a8df53e

File tree

2 files changed

+66
-50
lines changed

2 files changed

+66
-50
lines changed

noxfile.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
path.parent / f"{path.stem}.in" for path in REQUIREMENTS.values()
1818
]
1919

20-
SUPPORTED = ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.10"]
21-
LATEST = "3.12"
20+
SUPPORTED = ["3.8", "3.9", "3.10", "pypy3.10", "3.11", "3.12"]
21+
LATEST = SUPPORTED[-1]
2222

2323
nox.options.sessions = []
2424

@@ -45,7 +45,7 @@ def tests(session):
4545

4646
if session.posargs and session.posargs[0] == "coverage":
4747
if len(session.posargs) > 1 and session.posargs[1] == "github":
48-
github = os.environ["GITHUB_STEP_SUMMARY"]
48+
github = Path(os.environ["GITHUB_STEP_SUMMARY"])
4949
else:
5050
github = None
5151

@@ -54,7 +54,7 @@ def tests(session):
5454
if github is None:
5555
session.run("coverage", "report")
5656
else:
57-
with open(github, "a") as summary:
57+
with github.open("a") as summary:
5858
summary.write("### Coverage\n\n")
5959
summary.flush() # without a flush, output seems out of order.
6060
session.run(
@@ -93,7 +93,7 @@ def style(session):
9393
Check Python code style.
9494
"""
9595
session.install("ruff")
96-
session.run("ruff", "check", ROOT)
96+
session.run("ruff", "check", ROOT, __file__)
9797

9898

9999
@session()
@@ -102,7 +102,7 @@ def typing(session):
102102
Check static typing.
103103
"""
104104
session.install("pyright", ROOT)
105-
session.run("pyright", PACKAGE)
105+
session.run("pyright", *session.posargs, PACKAGE)
106106

107107

108108
@session(tags=["docs"])
@@ -158,7 +158,9 @@ def docs_style(session):
158158
@session(default=False)
159159
def requirements(session):
160160
"""
161-
Update the project's pinned requirements. Commit the result.
161+
Update the project's pinned requirements.
162+
163+
You should commit the result afterwards.
162164
"""
163165
session.install("pip-tools")
164166
for each in REQUIREMENTS_IN:

pyproject.toml

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ skip_covered = true
6161

6262
[tool.doc8]
6363
ignore = [
64+
"D000", # see PyCQA/doc8#125
6465
"D001", # one sentence per line, so max length doesn't make sense
6566
]
6667

@@ -82,51 +83,64 @@ exclude = [
8283

8384
[tool.ruff]
8485
line-length = 79
85-
select = [
86-
"ANN", "B", "D", "D204", "E", "F", "Q", "RUF", "SIM", "TCH", "UP", "W",
87-
]
86+
87+
[tool.ruff.lint]
88+
select = ["ALL"]
8889
ignore = [
89-
# Wat, type annotations for self and cls, why is this a thing?
90-
"ANN101",
91-
"ANN102",
92-
# Private annotations are fine to leave out.
93-
"ANN202",
94-
# I don't know how to more properly annotate "pass along all arguments".
95-
"ANN401",
96-
# It's totally OK to call functions for default arguments.
97-
"B008",
98-
# raise SomeException(...) is fine.
99-
"B904",
100-
# There's no need for explicit strict, this is simply zip's default behavior.
101-
"B905",
102-
# It's fine to not have docstrings for magic methods.
103-
"D105",
104-
# __init__ especially doesn't need a docstring
105-
"D107",
106-
# This rule makes diffs uglier when expanding docstrings (and it's uglier)
107-
"D200",
108-
# No blank lines before docstrings.
109-
"D203",
110-
# Start docstrings on the second line.
111-
"D212",
112-
# This rule misses sassy docstrings ending with ! or ?.
113-
"D400",
114-
# Section headers should end with a colon not a newline
115-
"D406",
116-
# Underlines aren't needed
117-
"D407",
118-
# Plz spaces after section headers
119-
"D412",
120-
# Not sure what heuristic this uses, but it seems easy for it to be wrong.
121-
"SIM300",
122-
# We support 3.8 + 3.9
123-
"UP007",
90+
"A001", # It's fine to shadow builtins
91+
"A002",
92+
"A003",
93+
"ARG", # This is all wrong whenever an interface is involved
94+
"ANN", # Just let the type checker do this
95+
"B006", # Mutable arguments require care but are OK if you don't abuse them
96+
"B008", # It's totally OK to call functions for default arguments.
97+
"B904", # raise SomeException(...) is fine.
98+
"B905", # No need for explicit strict, this is simply zip's default behavior
99+
"C408", # Calling dict is fine when it saves quoting the keys
100+
"C901", # Not really something to focus on
101+
"D105", # It's fine to not have docstrings for magic methods.
102+
"D107", # __init__ especially doesn't need a docstring
103+
"D200", # This rule makes diffs uglier when expanding docstrings
104+
"D203", # No blank lines before docstrings.
105+
"D212", # Start docstrings on the second line.
106+
"D400", # This rule misses sassy docstrings ending with ! or ?
107+
"D401", # This rule is too flaky.
108+
"D406", # Section headers should end with a colon not a newline
109+
"D407", # Underlines aren't needed
110+
"D412", # Plz spaces after section headers
111+
"EM101", # These don't bother me, it's fine there's some duplication.
112+
"EM102",
113+
"FBT", # It's worth avoiding boolean args but I don't care to enforce it
114+
"FIX", # Yes thanks, if I could it wouldn't be there
115+
"N", # These naming rules are silly
116+
"PLR0912", # These metrics are fine to be aware of but not to enforce
117+
"PLR0913",
118+
"PLR0915",
119+
"PLW2901", # Shadowing for loop variables is occasionally fine.
120+
"PT006", # pytest parametrize takes strings as well
121+
"PYI025", # wat, I'm not confused, thanks.
122+
"RET502", # Returning None implicitly is fine
123+
"RET503",
124+
"RET505", # These push you to use `if` instead of `elif`, but for no reason
125+
"RET506",
126+
"RSE102", # Ha, what, who even knew you could leave the parens off. But no.
127+
"SIM300", # Not sure what heuristic this uses, but it's easily incorrect
128+
"SLF001", # Private usage within this package itself is fine
129+
"TD", # These TODO style rules are also silly
130+
"UP007", # We support 3.8 + 3.9
124131
]
125132

126-
[tool.ruff.flake8-quotes]
133+
[tool.ruff.lint.flake8-pytest-style]
134+
mark-parentheses = false
135+
136+
[tool.ruff.lint.flake8-quotes]
127137
docstring-quotes = "double"
128138

129-
[tool.ruff.per-file-ignores]
130-
"noxfile.py" = ["ANN", "D100"]
131-
"docs/*" = ["ANN", "D"]
132-
"referencing_loaders/tests/*" = ["ANN", "D", "RUF012"]
139+
[tool.ruff.lint.isort]
140+
combine-as-imports = true
141+
from-first = true
142+
143+
[tool.ruff.lint.per-file-ignores]
144+
"noxfile.py" = ["ANN", "D100", "S101", "T201"]
145+
"docs/*" = ["ANN", "D", "INP001"]
146+
"referencing_loaders/tests/*" = ["ANN", "D", "RUF012", "S", "PLR", "TRY"]

0 commit comments

Comments
 (0)