From 5799223b3d5403285e36b770b9c9efeeae216706 Mon Sep 17 00:00:00 2001 From: Nick Murphy Date: Tue, 2 Jul 2024 20:14:38 -0400 Subject: [PATCH] Add nox sessions for building package & running mypy --- noxfile.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/noxfile.py b/noxfile.py index 847bf1c..fbbeb9a 100644 --- a/noxfile.py +++ b/noxfile.py @@ -5,14 +5,14 @@ @nox.session -def tests(session): +def tests(session: nox.Session) -> None: """Run tests with pytest.""" session.install(".") - session.run("pytest") + session.run("pytest", *session.posargs) @nox.session -def docs(session): +def docs(session: nox.Session) -> None: """Build documentation with Sphinx.""" session.install(".") session.run( @@ -21,4 +21,29 @@ def docs(session): "docs/build/html", "--builder", "html", + *session.posargs, ) + + +@nox.session +def build(session: nox.Session) -> None: + """Build & verify the source distribution and wheel.""" + session.install("twine", "build") + build_command = ("python", "-m", "build") + session.run(*build_command, "--sdist") + session.run(*build_command, "--wheel") + session.run("twine", "check", "dist/*") + + +@nox.session +def mypy(session: nox.Session) -> None: + """Perform static type checking with mypy.""" + MYPY_COMMAND: tuple[str, ...] = ( + "mypy", + ".", + "--show-error-context", + "--show-error-code-links", + "--pretty", + ) + session.install(".") + session.run(*MYPY_COMMAND, *session.posargs)