From 74576bbb51da56636595b686aa4167dd94541c6b Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 21 Jul 2026 04:54:02 +0000 Subject: [PATCH] Make full-package mypy pass on the Python 3.8 CI (older mypy) The Python 3.8 CI job installs an older mypy that behaves differently from newer releases, surfacing two things the newer local mypy did not: - requests (and other stub-less deps) raise `import-untyped`, which older mypy does not silence via ignore_missing_imports. Add `disable_error_code = import-untyped` so stub-less third-party libs are treated as untyped rather than failing the run. - TandemSourceApi.__init__: older mypy infers secret.TCONNECT_REGION as Optional[str], so region.upper() tripped union-attr. Guard against an unset region (also avoids an AttributeError at runtime) which narrows it to str. Verified with both mypy 1.19.1 and 2.3.0; tests still green (461 passed). Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01UaQXTakxAKEfeeys5cv3en --- setup.cfg | 3 +++ tconnectsync/api/tandemsource.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/setup.cfg b/setup.cfg index b8fff52..6dd9111 100644 --- a/setup.cfg +++ b/setup.cfg @@ -53,3 +53,6 @@ files = tconnectsync follow_imports = silent ignore_missing_imports = True +# Third-party deps such as requests ship no type stubs; treat them as untyped +# instead of failing (older mypy does not silence this via ignore_missing_imports). +disable_error_code = import-untyped diff --git a/tconnectsync/api/tandemsource.py b/tconnectsync/api/tandemsource.py index a530715..a02aeb2 100644 --- a/tconnectsync/api/tandemsource.py +++ b/tconnectsync/api/tandemsource.py @@ -221,6 +221,8 @@ class TandemSourceApi: # US default would send EU accounts to the US endpoints (#152). if not region: region = secret.TCONNECT_REGION + if not region: + raise ValueError("No region configured. Set TCONNECT_REGION to 'US' or 'EU'.") self.region = region.upper() if self.region not in ['US', 'EU']: raise ValueError(f"Invalid region '{region}'. Must be 'US' or 'EU'.")