From 1a46f61bc32c7118e781b2d8fdb77f7810c232c2 Mon Sep 17 00:00:00 2001 From: Matt Spinola Date: Tue, 14 Jul 2026 12:09:40 -0400 Subject: [PATCH] fix: make PEP 604 union annotations import-safe on Python 3.9 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 --- src/cotdata/providers/cftc.py | 2 ++ src/cotdata/providers/norgate.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/cotdata/providers/cftc.py b/src/cotdata/providers/cftc.py index 72c1d29..f8cc757 100644 --- a/src/cotdata/providers/cftc.py +++ b/src/cotdata/providers/cftc.py @@ -7,6 +7,8 @@ Self-contained — no cot-analyzer imports. Ported from cot-analyzer/src/core/etl.py. """ +from __future__ import annotations # PEP 604 unions (Path | None) on Python 3.9 + import datetime as dt import io import zipfile diff --git a/src/cotdata/providers/norgate.py b/src/cotdata/providers/norgate.py index b2620e7..f8d1245 100644 --- a/src/cotdata/providers/norgate.py +++ b/src/cotdata/providers/norgate.py @@ -8,6 +8,8 @@ e.g. +146 pts at the 2026-06 Jun→Sep roll). '&ES_CCB' is BACK-ADJUSTED (gaps stitched out). A close-based stop needs the gap-free series → we fetch _CCB. """ +from __future__ import annotations # PEP 604 unions (dict | None) on Python 3.9 + import pandas as pd import numpy as np import re