File
sdks/python/pmxt/models.py
Missing Optional + Bare Built-in Generics (Python 3.9+ syntax)
Lines 483–489 in the SubscribedAddressSnapshot dataclass use the list[T] built-in generic form, which requires Python 3.9+:
| Line |
Current |
Required for Python 3.8 |
| 483 |
trades: Optional[list[Trade]] = None |
Optional[List[Trade]] |
| 485 |
positions: Optional[list[Position]] = None |
Optional[List[Position]] |
| 487 |
balances: Optional[list[Balance]] = None |
Optional[List[Balance]] |
On Python 3.8, the dataclass decorator evaluates field annotations at class-definition time. list[Trade] raises:
TypeError: 'type' object is not subscriptable
immediately on import pmxt.
Inconsistency
Every other collection type in models.py correctly uses List[T] from typing (e.g., outcomes: List[MarketOutcome], tags: Optional[List[str]]). These three fields are the only outliers — likely written on a Python 3.9+ machine and not caught because disallow_untyped_defs = false and tests presumably ran on Python 3.9+.
Impact
- HIGH:
SubscribedAddressSnapshot is the public return type of watch_address(). Any user on Python 3.8 calling watch_address() will receive a crash at import time before the call is even reached.
- This also affects type checkers:
list[Trade] is not List[Trade] in older mypy versions that target Python 3.8 semantics.
Suggested Fix
from typing import List, Optional # already imported at top of file
@dataclass
class SubscribedAddressSnapshot:
address: str
timestamp: int
trades: Optional[List[Trade]] = None
positions: Optional[List[Position]] = None
balances: Optional[List[Balance]] = None
Found by automated Python type hints audit
File
sdks/python/pmxt/models.pyMissing Optional + Bare Built-in Generics (Python 3.9+ syntax)
Lines 483–489 in the
SubscribedAddressSnapshotdataclass use thelist[T]built-in generic form, which requires Python 3.9+:trades: Optional[list[Trade]] = NoneOptional[List[Trade]]positions: Optional[list[Position]] = NoneOptional[List[Position]]balances: Optional[list[Balance]] = NoneOptional[List[Balance]]On Python 3.8, the dataclass decorator evaluates field annotations at class-definition time.
list[Trade]raises:immediately on
import pmxt.Inconsistency
Every other collection type in
models.pycorrectly usesList[T]fromtyping(e.g.,outcomes: List[MarketOutcome],tags: Optional[List[str]]). These three fields are the only outliers — likely written on a Python 3.9+ machine and not caught becausedisallow_untyped_defs = falseand tests presumably ran on Python 3.9+.Impact
SubscribedAddressSnapshotis the public return type ofwatch_address(). Any user on Python 3.8 callingwatch_address()will receive a crash at import time before the call is even reached.list[Trade]is notList[Trade]in older mypy versions that target Python 3.8 semantics.Suggested Fix
Found by automated Python type hints audit