Skip to content

Commit 1e79632

Browse files
committed
Some extra style rules and docstrings for the noxfile.
1 parent a177b74 commit 1e79632

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

noxfile.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
nox.options.sessions = []
1414

1515

16-
def session(default=True, **kwargs):
16+
def session(default=True, **kwargs): # noqa: D103
1717
def _session(fn):
1818
if default:
1919
nox.options.sessions.append(kwargs.get("name", fn.__name__))
@@ -24,19 +24,28 @@ def _session(fn):
2424

2525
@session(python=["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3"])
2626
def tests(session):
27+
"""
28+
Run the test suite with a corresponding Python version.
29+
"""
2730
session.install("pytest", ROOT)
2831
env = dict(os.environ, PYTHONWARNDEFAULTENCODING="1")
2932
session.run("pytest", "--verbosity=3", "--pythonwarnings=error", env=env)
3033

3134

3235
@session()
3336
def audit(session):
37+
"""
38+
Audit dependencies for vulnerabilities.
39+
"""
3440
session.install("pip-audit", ROOT)
3541
session.run("python", "-m", "pip_audit")
3642

3743

3844
@session(tags=["build"])
3945
def build(session):
46+
"""
47+
Build a distribution suitable for PyPI and check its validity.
48+
"""
4049
session.install("build", "twine")
4150
with TemporaryDirectory() as tmpdir:
4251
session.run("python", "-m", "build", ROOT, "--outdir", tmpdir)
@@ -45,12 +54,18 @@ def build(session):
4554

4655
@session(tags=["style"])
4756
def style(session):
57+
"""
58+
Check Python code style.
59+
"""
4860
session.install("ruff")
4961
session.run("ruff", "check", ROOT)
5062

5163

5264
@session()
5365
def typing(session):
66+
"""
67+
Check static typing.
68+
"""
5469
session.install("mypy", ROOT)
5570
session.run("python", "-m", "mypy", PACKAGE)
5671

@@ -70,26 +85,33 @@ def typing(session):
7085
],
7186
)
7287
def docs(session, builder):
88+
"""
89+
Build the documentation using a specific Sphinx builder.
90+
"""
7391
session.install("-r", DOCS / "requirements.txt")
7492
with TemporaryDirectory() as tmpdir_str:
7593
tmpdir = Path(tmpdir_str)
7694
argv = ["-n", "-T", "-W"]
7795
if builder != "spelling":
7896
argv += ["-q"]
97+
posargs = session.posargs or [tmpdir / builder]
7998
session.run(
8099
"python",
81100
"-m",
82101
"sphinx",
83102
"-b",
84103
builder,
85104
DOCS,
86-
tmpdir / builder,
87105
*argv,
106+
*posargs,
88107
)
89108

90109

91110
@session(tags=["docs", "style"], name="docs(style)")
92111
def docs_style(session):
112+
"""
113+
Check the documentation style.
114+
"""
93115
session.install(
94116
"doc8",
95117
"pygments",
@@ -109,6 +131,7 @@ def requirements(session):
109131
"pip-compile",
110132
"--resolver",
111133
"backtracking",
134+
"--strip-extras",
112135
"-U",
113136
each.relative_to(ROOT),
114137
)

pyproject.toml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ authors = [
2424
]
2525
classifiers = [
2626
"Development Status :: 5 - Production/Stable",
27+
"Intended Audience :: Developers",
2728
"License :: OSI Approved :: MIT License",
2829
"Operating System :: OS Independent",
2930
"Programming Language :: Python",
@@ -82,7 +83,7 @@ multi_line_output = 3
8283
[tool.ruff]
8384
line-length = 79
8485
target-version = "py38"
85-
select = ["ANN", "B", "D", "E", "F", "Q", "UP", "W"]
86+
select = ["ANN", "B", "D", "D204", "E", "F", "Q", "RUF", "SIM", "UP", "W"]
8687
ignore = [
8788
# Wat, type annotations for self and cls, why is this a thing?
8889
"ANN101",
@@ -91,10 +92,16 @@ ignore = [
9192
"ANN202",
9293
# I don't know how to more properly annotate "pass along all arguments".
9394
"ANN401",
95+
# It's totally OK to call functions for default arguments.
96+
"B008",
9497
# raise SomeException(...) is fine.
9598
"B904",
99+
# There's no need for explicit strict, this is simply zip's default behavior.
100+
"B905",
96101
# It's fine to not have docstrings for magic methods.
97102
"D105",
103+
# __init__ especially doesn't need a docstring
104+
"D107",
98105
# This rule makes diffs uglier when expanding docstrings (and it's uglier)
99106
"D200",
100107
# No blank lines before docstrings.
@@ -118,6 +125,6 @@ extend-exclude = ["suite"]
118125
docstring-quotes = "double"
119126

120127
[tool.ruff.per-file-ignores]
128+
"noxfile.py" = ["ANN", "D100"]
121129
"docs/*" = ["ANN", "D"]
122-
"jsonschema_specifications/tests/*" = ["ANN", "D"]
123-
"noxfile.py" = ["ANN", "D"]
130+
"jsonschema_specifications/tests/*" = ["ANN", "D", "RUF012"]

0 commit comments

Comments
 (0)