diff --git a/noxfile.py b/noxfile.py index 85b635e..56a02ff 100644 --- a/noxfile.py +++ b/noxfile.py @@ -13,7 +13,7 @@ nox.options.sessions = [] -def session(default=True, **kwargs): +def session(default=True, **kwargs): # noqa: D103 def _session(fn): if default: nox.options.sessions.append(kwargs.get("name", fn.__name__)) @@ -24,6 +24,9 @@ def _session(fn): @session(python=["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3"]) def tests(session): + """ + Run the test suite with a corresponding Python version. + """ session.install("pytest", ROOT) env = dict(os.environ, PYTHONWARNDEFAULTENCODING="1") session.run("pytest", "--verbosity=3", "--pythonwarnings=error", env=env) @@ -31,12 +34,18 @@ def tests(session): @session() def audit(session): + """ + Audit dependencies for vulnerabilities. + """ session.install("pip-audit", ROOT) session.run("python", "-m", "pip_audit") @session(tags=["build"]) def build(session): + """ + Build a distribution suitable for PyPI and check its validity. + """ session.install("build", "twine") with TemporaryDirectory() as tmpdir: session.run("python", "-m", "build", ROOT, "--outdir", tmpdir) @@ -45,12 +54,18 @@ def build(session): @session(tags=["style"]) def style(session): + """ + Check Python code style. + """ session.install("ruff") session.run("ruff", "check", ROOT) @session() def typing(session): + """ + Check static typing. + """ session.install("mypy", ROOT) session.run("python", "-m", "mypy", PACKAGE) @@ -70,12 +85,16 @@ def typing(session): ], ) def docs(session, builder): + """ + Build the documentation using a specific Sphinx builder. + """ session.install("-r", DOCS / "requirements.txt") with TemporaryDirectory() as tmpdir_str: tmpdir = Path(tmpdir_str) argv = ["-n", "-T", "-W"] if builder != "spelling": argv += ["-q"] + posargs = session.posargs or [tmpdir / builder] session.run( "python", "-m", @@ -83,13 +102,16 @@ def docs(session, builder): "-b", builder, DOCS, - tmpdir / builder, *argv, + *posargs, ) @session(tags=["docs", "style"], name="docs(style)") def docs_style(session): + """ + Check the documentation style. + """ session.install( "doc8", "pygments", @@ -109,6 +131,7 @@ def requirements(session): "pip-compile", "--resolver", "backtracking", + "--strip-extras", "-U", each.relative_to(ROOT), ) diff --git a/pyproject.toml b/pyproject.toml index 835c2af..262310b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ authors = [ ] classifiers = [ "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", @@ -82,7 +83,7 @@ multi_line_output = 3 [tool.ruff] line-length = 79 target-version = "py38" -select = ["ANN", "B", "D", "E", "F", "Q", "UP", "W"] +select = ["ANN", "B", "D", "D204", "E", "F", "Q", "RUF", "SIM", "UP", "W"] ignore = [ # Wat, type annotations for self and cls, why is this a thing? "ANN101", @@ -91,10 +92,16 @@ ignore = [ "ANN202", # I don't know how to more properly annotate "pass along all arguments". "ANN401", + # It's totally OK to call functions for default arguments. + "B008", # raise SomeException(...) is fine. "B904", + # There's no need for explicit strict, this is simply zip's default behavior. + "B905", # It's fine to not have docstrings for magic methods. "D105", + # __init__ especially doesn't need a docstring + "D107", # This rule makes diffs uglier when expanding docstrings (and it's uglier) "D200", # No blank lines before docstrings. @@ -118,6 +125,6 @@ extend-exclude = ["suite"] docstring-quotes = "double" [tool.ruff.per-file-ignores] +"noxfile.py" = ["ANN", "D100"] "docs/*" = ["ANN", "D"] -"jsonschema_specifications/tests/*" = ["ANN", "D"] -"noxfile.py" = ["ANN", "D"] +"jsonschema_specifications/tests/*" = ["ANN", "D", "RUF012"]