1313nox .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" ])
2626def 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 ()
3336def 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" ])
3945def 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" ])
4756def style (session ):
57+ """
58+ Check Python code style.
59+ """
4860 session .install ("ruff" )
4961 session .run ("ruff" , "check" , ROOT )
5062
5163
5264@session ()
5365def 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)
7287def 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)" )
92111def 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 )
0 commit comments