feat: add ty type checker alongside mypy (#77)

Add Astral's ty type checker (written in Rust, 10-100x faster than mypy)
as a second type checking layer. Both run in pre-commit and CI.

Fixed type issues caught by ty:
- config.py: explicit Host constructor to avoid dict unpacking issues
- executor.py: wrap subprocess.run in closure for asyncio.to_thread
- api.py: use getattr for Jinja TemplateModule macro access
- test files: fix playwright driver_path tuple handling, pytest rootpath typing
This commit is contained in:
Bas Nijholt
2025-12-20 15:43:51 -08:00
committed by GitHub
parent 6d50f90344
commit bb019bcae6
9 changed files with 75 additions and 17 deletions

View File

@@ -16,7 +16,9 @@ def _make_config(tmp_path: Path, services: dict[str, str] | None = None) -> Conf
compose_dir = tmp_path / "compose"
compose_dir.mkdir()
svc_dict = services or {"svc1": "host1", "svc2": "host2"}
svc_dict: dict[str, str | list[str]] = (
dict(services) if services else {"svc1": "host1", "svc2": "host2"}
)
for svc in svc_dict:
svc_dir = compose_dir / svc
svc_dir.mkdir()

View File

@@ -44,7 +44,9 @@ def _browser_available() -> bool:
try:
from playwright._impl._driver import compute_driver_executable
driver_path = compute_driver_executable()
driver_info = compute_driver_executable()
# compute_driver_executable returns (driver_path, browser_path) tuple
driver_path = driver_info[0] if isinstance(driver_info, tuple) else driver_info
return Path(driver_path).exists()
except Exception:
return False
@@ -63,7 +65,7 @@ pytestmark = [
@pytest.fixture(scope="session")
def vendor_cache(request: pytest.FixtureRequest) -> Path:
"""Download CDN assets once and cache to disk for faster tests."""
cache_dir = Path(request.config.rootdir) / ".pytest_cache" / "vendor"
cache_dir = Path(request.config.rootpath) / ".pytest_cache" / "vendor"
return ensure_vendor_cache(cache_dir)