Skip to content

Commit

Permalink
Polish nox setup (#185)
Browse files Browse the repository at this point in the history
* Type noxfile

* Define all nox Python versions once
  • Loading branch information
jodal committed Mar 11, 2023
1 parent 059bc69 commit adcc922
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
32 changes: 18 additions & 14 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,61 @@
package = "biip"
locations = ["src", "tests", "noxfile.py", "docs/conf.py"]

supported_pythons = ["3.7", "3.8", "3.9", "3.10", "3.11"]
coverage_python = "3.11"
docs_python = "3.11"

@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"])
def tests(session):

@nox.session(python=supported_pythons)
def tests(session: nox.Session) -> None:
"""Run the test suite."""
args = session.posargs or ["--cov"]
session.run("poetry", "install", "--all-extras", "--only=main,tests", external=True)
session.run("pytest", *args)


@nox.session(python="3.11")
def coverage(session):
@nox.session(python=coverage_python)
def coverage(session: nox.Session) -> None:
"""Upload test coverage data."""
session.run("poetry", "install", "--no-root", "--only=tests", external=True)
session.run("coverage", "xml", "--fail-under=0")
session.run("codecov", *session.posargs)


@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"])
def black(session):
@nox.session(python=supported_pythons)
def black(session: nox.Session) -> None:
"""Check formatting using Black."""
args = session.posargs or locations
session.run("poetry", "install", "--no-root", "--only=black", external=True)
session.run("black", *args)


@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"])
def ruff(session):
@nox.session(python=supported_pythons)
def ruff(session: nox.Session) -> None:
"""Lint using ruff."""
args = session.posargs or locations
session.run("poetry", "install", "--no-root", "--only=ruff", external=True)
session.run("ruff", *args)


@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"])
def darglint(session):
@nox.session(python=supported_pythons)
def darglint(session: nox.Session) -> None:
"""Check docstrings using darglint."""
args = session.posargs or ["src"]
session.run("poetry", "install", "--no-root", "--only=darglint", external=True)
session.run("darglint", *args)


@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"])
def mypy(session):
@nox.session(python=supported_pythons)
def mypy(session: nox.Session) -> None:
"""Type-check using mypy."""
args = session.posargs or locations
session.run("poetry", "install", "--only=mypy", external=True)
session.run("mypy", *args)


@nox.session(python="3.11")
def docs(session):
@nox.session(python=docs_python)
def docs(session: nox.Session) -> None:
"""Build the documentation."""
session.run("poetry", "install", "--all-extras", "--only=main,docs", external=True)
session.run("sphinx-build", "docs", "docs/_build")
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ target-version = "py37"

[tool.ruff.per-file-ignores]
"docs/*" = ["INP001"]
"noxfile.py" = ["ANN"]
"scripts/*" = ["INP001", "T20"]
"tests/*" = ["D"]

Expand Down

0 comments on commit adcc922

Please sign in to comment.