Type-check scripts/

This commit is contained in:
Alexander Hess 2026-12-01 13:57:42 +01:00
commit d6b798a736
Signed by: alexander
GPG key ID: B46EDB4DFC26805D
2 changed files with 9 additions and 6 deletions

View file

@ -89,6 +89,8 @@ PACKAGE_LOCATION = "src/"
DOCS_BUILD = ".cache/docs/" DOCS_BUILD = ".cache/docs/"
DOCS_LOCATION = "docs/" DOCS_LOCATION = "docs/"
SCRIPTS_LOCATION = "scripts/"
TESTS_LOCATION = "tests/" TESTS_LOCATION = "tests/"
# Locations of all *.py files # Locations of all *.py files
@ -97,7 +99,7 @@ SRC_LOCATIONS = (
"migrations/env.py", "migrations/env.py",
"migrations/versions/", "migrations/versions/",
NOXFILE_LOCATION, NOXFILE_LOCATION,
"scripts/", SCRIPTS_LOCATION,
PACKAGE_LOCATION, PACKAGE_LOCATION,
TESTS_LOCATION, TESTS_LOCATION,
) )
@ -186,7 +188,7 @@ def lint_code(session: nox.Session) -> None:
If no extra arguments are provided, all source files are linted. If no extra arguments are provided, all source files are linted.
Otherwise, they are interpreted as paths the linters work on recursively. Otherwise, they are interpreted as paths the linters work on recursively.
`mypy` always checks the noxfile and the entire package regardless `mypy` always checks the noxfile, the scripts, and the package regardless
because it needs the whole program to follow types across modules. because it needs the whole program to follow types across modules.
""" """
start(session) start(session)
@ -250,7 +252,7 @@ def lint_code(session: nox.Session) -> None:
session.run("ruff", "check", *locations) session.run("ruff", "check", *locations)
session.run("mypy", "--version") session.run("mypy", "--version")
session.run("mypy", NOXFILE_LOCATION, PACKAGE_LOCATION) session.run("mypy", NOXFILE_LOCATION, SCRIPTS_LOCATION, PACKAGE_LOCATION)
@nox.session(name="test", python=MAIN_PYTHON) @nox.session(name="test", python=MAIN_PYTHON)

View file

@ -14,6 +14,7 @@ import json
import pathlib import pathlib
import textwrap import textwrap
import tomllib import tomllib
import typing as t
PKG_CONSIDERED_OLD = 2 # years after release when a package is considered "old" PKG_CONSIDERED_OLD = 2 # years after release when a package is considered "old"
@ -23,7 +24,7 @@ PROJECT_ROOT = pathlib.Path(__file__).resolve().parent.parent
REPORT_FILE = PROJECT_ROOT / ".cache/dependencies_checked.txt" REPORT_FILE = PROJECT_ROOT / ".cache/dependencies_checked.txt"
def get_direct_dependencies(lock_file: dict) -> dict[str, str]: def get_direct_dependencies(lock_file: dict[str, t.Any]) -> dict[str, str]:
"""Map the direct dependencies to "main" or their extra or group. """Map the direct dependencies to "main" or their extra or group.
`lock_file` is a mapping as returned from `load_lock_file()`. `lock_file` is a mapping as returned from `load_lock_file()`.
@ -41,7 +42,7 @@ def get_direct_dependencies(lock_file: dict) -> dict[str, str]:
return labels return labels
def get_pinned_packages(lock_file: dict) -> dict[str, str]: def get_pinned_packages(lock_file: dict[str, t.Any]) -> dict[str, str]:
"""Map all packages from PyPI to their versions. """Map all packages from PyPI to their versions.
`lock_file` is a mapping as returned from `load_lock_file()`. `lock_file` is a mapping as returned from `load_lock_file()`.
@ -84,7 +85,7 @@ def get_years_since_release(
return round(years_since_release, 1), latest_version return round(years_since_release, 1), latest_version
def load_lock_file() -> dict: def load_lock_file() -> dict[str, t.Any]:
"""Load the uv.lock file.""" """Load the uv.lock file."""
return tomllib.loads((PROJECT_ROOT / "uv.lock").read_text()) return tomllib.loads((PROJECT_ROOT / "uv.lock").read_text())