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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies = [
"python-dateutil>=2.8.2",
"loguru>=0.7.3",
"python-dotenv>=1.0.0",
"sniffio>=1.3.0",
]

[tool.ty.environment]
Expand Down
34 changes: 34 additions & 0 deletions tests/acceptance/test_runtime_dependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Guard: runtime dependencies required for performance must be declared and installed.

httpcore retries ``import sniffio`` on every lock/event/cancel-shield call when
sniffio is absent (encode/httpcore#1103), costing ~17% CPU per request on the
async client. Ensure it is both declared and importable.
"""

import importlib.util
import re
from pathlib import Path

PYPROJECT = Path(__file__).resolve().parents[2] / "pyproject.toml"


def _declared_names() -> set[str]:
# Plain-text parse: tomllib is unavailable on Python 3.10.
match = re.search(r"^dependencies = \[(.*?)^\]", PYPROJECT.read_text(), re.S | re.M)
assert match, "dependencies block not found in pyproject.toml"
deps = re.findall(r'"([^"]+)"', match.group(1))
names: set[str] = set()
for dep in deps:
name = dep
for sep in "<>=!~;[ ":
name = name.split(sep)[0]
names.add(name.strip().lower())
return names


def test_sniffio_declared_as_runtime_dependency() -> None:
assert "sniffio" in _declared_names()


def test_sniffio_installed() -> None:
assert importlib.util.find_spec("sniffio") is not None
117 changes: 64 additions & 53 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading