"""Packaging contract: a PEP 561 typed package with exactly one dependency. Consumers run mypy --strict against the inline annotations; without the py.typed marker mypy degrades every imported symbol to Any. """ from __future__ import annotations from pathlib import Path import pytest import llm_ingestion_okf PROJECT_ROOT = Path(__file__).resolve().parents[1] def test_package_ships_py_typed_marker() -> None: package_dir = Path(llm_ingestion_okf.__file__).parent assert (package_dir / "py.typed").is_file() def test_the_only_runtime_dependency_is_the_security_boundary() -> None: """The stdlib-only rule, enforced rather than asserted in prose. One dependency is permitted — the guard — because security is the one thing this library must not implement. Everything else stays stdlib, so a consumer vendoring this package takes on no transitive surface. The version RANGE is the pin: it resolves against a package index, and is satisfied by the git+https tag install until that index exists. """ tomllib = pytest.importorskip("tomllib") # stdlib from 3.11; the pin holds on 3.10 too pyproject = tomllib.loads((PROJECT_ROOT / "pyproject.toml").read_text(encoding="utf-8")) assert pyproject["project"]["dependencies"] == ["llm-ingestion-guard>=0.2,<0.3"] def test_the_declared_version_agrees_with_the_packaged_one() -> None: """The two places a version is written must not drift apart. The install channel is a direct git reference, so a consumer pins a TAG while pip records `project.version`. Nothing in the run path reads `__version__` — which is exactly why a stale one survives a green suite, and why a consumer installing at a pre-release tag can end up with a package that reports the previous release. This is the only machine check on that; the tag name itself remains a human step. """ tomllib = pytest.importorskip("tomllib") pyproject = tomllib.loads((PROJECT_ROOT / "pyproject.toml").read_text(encoding="utf-8")) assert llm_ingestion_okf.__version__ == pyproject["project"]["version"]