Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"template": "https://github.com/statisticsnorway/ssb-pypitemplate.git",
"commit": "9e3c49f6680d4c400567c39d70b768f0a322c95e",
"checkout": "2025.7.18",
"commit": "1b94f545381a9ce08e205e7451d7a4f07eaef142",
"checkout": null,
"context": {
"cookiecutter": {
"project_name": "ssb-vaskify",
Expand All @@ -26,7 +26,7 @@
"trim_blocks": true
},
"_template": "https://github.com/statisticsnorway/ssb-pypitemplate.git",
"_commit": "9e3c49f6680d4c400567c39d70b768f0a322c95e"
"_commit": "1b94f545381a9ce08e205e7451d7a4f07eaef142"
}
},
"directory": null
Expand Down
2 changes: 0 additions & 2 deletions .darglint

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
subprocess.run(cmd, shell=True)

- name: Restore pre-commit cache
uses: actions/cache@v4
uses: actions/cache@v5
if: matrix.session == 'pre-commit'
with:
path: ~/.cache/pre-commit
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ repos:
entry: check-ast
language: system
types: [python]
- id: darglint
name: darglint
entry: darglint
- id: pydoclint
name: pydoclint
entry: pydoclint
language: system
types: [python]
- id: ruff
Expand Down
56 changes: 30 additions & 26 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shlex
import shutil
import sys
import tempfile
from pathlib import Path
from textwrap import dedent

Expand All @@ -25,7 +26,7 @@
package = "vaskify"
python_versions = ["3.11", "3.12", "3.13"]
python_versions_for_test = python_versions + ["3.10"]
nox.needs_version = ">= 2021.6.6"
nox.needs_version = ">= 2025.2.9"
nox.options.sessions = (
"pre-commit",
"mypy",
Expand All @@ -36,6 +37,26 @@
)


def install_poetry_groups(session: Session, *groups: str) -> None:
"""Install dependencies from poetry groups, pinned to poetry.lock

Using this as a workaround until this PR is merged in:
https://github.com/cjolowicz/nox-poetry/pull/1080
"""
with tempfile.TemporaryDirectory() as tempdir:
requirements_path = os.path.join(tempdir, "requirements.txt")
session.run(
"poetry",
"export",
*[f"--only={group}" for group in groups],
"--format=requirements.txt",
"--without-hashes",
f"--output={requirements_path}",
external=True,
)
session.install("-r", requirements_path)


def activate_virtualenv_in_precommit_hooks(session: Session) -> None:
"""Activate virtualenv in hooks installed by pre-commit.

Expand Down Expand Up @@ -128,13 +149,7 @@ def precommit(session: Session) -> None:
"--hook-stage=manual",
"--show-diff-on-failure",
]
session.install(
"pre-commit",
"pre-commit-hooks",
"darglint",
"ruff",
"black",
)
install_poetry_groups(session, "lint")
session.run("pre-commit", *args)
if args and args[0] == "install":
activate_virtualenv_in_precommit_hooks(session)
Expand All @@ -145,7 +160,7 @@ def mypy(session: Session) -> None:
"""Type-check using mypy."""
args = session.posargs or ["src", "tests"]
session.install(".")
session.install("mypy", "pytest")
install_poetry_groups(session, "dev")
session.run("mypy", *args)
if not session.posargs:
session.run("mypy", f"--python-executable={sys.executable}", "noxfile.py")
Expand All @@ -155,7 +170,7 @@ def mypy(session: Session) -> None:
def tests(session: Session) -> None:
"""Run the test suite."""
session.install(".")
session.install("coverage[toml]", "pytest", "pygments")
install_poetry_groups(session, "dev")
try:
session.run(
"coverage",
Expand All @@ -176,9 +191,7 @@ def tests(session: Session) -> None:
def coverage(session: Session) -> None:
"""Produce the coverage report."""
args = session.posargs or ["report", "--skip-empty"]

session.install("coverage[toml]")

install_poetry_groups(session, "dev")
if not session.posargs and any(Path().glob(".coverage.*")):
session.run("coverage", "combine")

Expand All @@ -189,7 +202,7 @@ def coverage(session: Session) -> None:
def typeguard(session: Session) -> None:
"""Runtime type checking using Typeguard."""
session.install(".")
session.install("pytest", "typeguard", "pygments")
install_poetry_groups(session, "dev")
session.run("pytest", f"--typeguard-packages={package}", *session.posargs)


Expand All @@ -204,7 +217,7 @@ def xdoctest(session: Session) -> None:
args.append("--colored=1")

session.install(".")
session.install("xdoctest[colors]")
install_poetry_groups(session, "dev")
session.run("python", "-m", "xdoctest", *args)


Expand All @@ -216,9 +229,7 @@ def docs_build(session: Session) -> None:
args.insert(0, "--color")

session.install(".")
session.install(
"sphinx", "sphinx-autodoc-typehints", "sphinx-click", "furo", "myst-parser"
)
install_poetry_groups(session, "doc")

build_dir = Path("docs", "_build")
if build_dir.exists():
Expand All @@ -232,14 +243,7 @@ def docs(session: Session) -> None:
"""Build and serve the documentation with live reloading on file changes."""
args = session.posargs or ["--open-browser", "docs", "docs/_build"]
session.install(".")
session.install(
"sphinx",
"sphinx-autobuild",
"sphinx-autodoc-typehints",
"sphinx-click",
"furo",
"myst-parser",
)
install_poetry_groups(session, "doc")

build_dir = Path("docs", "_build")
if build_dir.exists():
Expand Down
Loading