Skip to content

fix: make PEP 604 union annotations import-safe on Python 3.9#12

Merged
mspinola merged 1 commit into
mainfrom
fix/py39-union-annotations
Jul 14, 2026
Merged

fix: make PEP 604 union annotations import-safe on Python 3.9#12
mspinola merged 1 commit into
mainfrom
fix/py39-union-annotations

Conversation

@mspinola

Copy link
Copy Markdown
Owner

Fixes the red CI on main after the volume-reconstruction feature landed (#11).

Failure

src/cotdata/providers/norgate.py:240: in <module>
    def get_symbol_metadata(internal_symbol: str) -> dict | None:
E   TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

dict | None (PEP 604) is evaluated at import time and only works on Python 3.10+. The CI matrix includes 3.9 (requires-python = ">=3.9"), so collecting test_norgate_provider.py — which imports the norgate provider — fails. cftc._download_year had the same latent Path | None.

Fix

Add from __future__ import annotations to both provider modules, so every annotation is a lazy string and never evaluated at runtime. No behaviour change, and it future-proofs any further annotations in these files.

Verified

  • Annotations confirmed stored as strings ('dict | None', 'Path | None') → import-safe on 3.9.
  • Full suite: 31 passed locally (3.13).
  • Scanned src/ for any other PEP 604 unions — the only two are the ones fixed here.

🤖 Generated with Claude Code

CI (matrix incl. 3.9; requires-python >=3.9) failed collecting
test_norgate_provider.py: `dict | None` in norgate.get_symbol_metadata is
evaluated at import time and only works on 3.10+. cftc._download_year had the
same latent `Path | None`.

Add `from __future__ import annotations` to both provider modules so all
annotations are lazy strings, never evaluated at runtime. No behaviour change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mspinola
mspinola merged commit 229b689 into main Jul 14, 2026
5 checks passed
@mspinola
mspinola deleted the fix/py39-union-annotations branch July 14, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant