File
sdks/python/pmxt/_exchanges.py
Note: Issue #227 covers the same problem in Exchange.__init__ in client.py (line 267). This issue covers the identical problem in the auto-generated _exchanges.py, which the generator must also be fixed to address.
Excessive Any Usage (CRITICAL — public constructor)
Line 20 — Polymarket.__init__
signature_type: Optional[Any] = "gnosis-safe",
signature_type controls how Polymarket signs orders. Its valid values are a small, well-known set of strings ("EOA", "GNOSIS_SAFE", "gnosis-safe", etc.), but the annotation Optional[Any] tells the type checker nothing. Users receive no IDE hint about what values are legal.
Impact
- CRITICAL:
Polymarket is the most widely used exchange class in the SDK. Every user who tries to set signature_type= receives no IDE autocompletion and no static validation.
- mypy and pyright silently accept any value (e.g.,
Polymarket(signature_type=42)) with no warning.
Generator Note
This file is auto-generated by core/scripts/generate-python-exchanges.js. The fix must be applied in the generator template, not the generated file, otherwise it will be overwritten on the next npm run generate:sdk:all.
Suggested Fix
In the generator template, replace Optional[Any] with a concrete type for signature_type:
from typing import Literal, Optional
SignatureType = Literal["EOA", "GNOSIS_SAFE", "gnosis-safe"]
class Polymarket(Exchange):
def __init__(
self,
...,
signature_type: Optional[SignatureType] = "gnosis-safe",
...
): ...
If the full set of valid values is not stable enough to Literal-ize, Optional[str] is still a strict improvement over Optional[Any].
Found by automated Python type hints audit
File
sdks/python/pmxt/_exchanges.pyExcessive
AnyUsage (CRITICAL — public constructor)Line 20 —
Polymarket.__init__signature_typecontrols how Polymarket signs orders. Its valid values are a small, well-known set of strings ("EOA","GNOSIS_SAFE","gnosis-safe", etc.), but the annotationOptional[Any]tells the type checker nothing. Users receive no IDE hint about what values are legal.Impact
Polymarketis the most widely used exchange class in the SDK. Every user who tries to setsignature_type=receives no IDE autocompletion and no static validation.Polymarket(signature_type=42)) with no warning.Generator Note
This file is auto-generated by
core/scripts/generate-python-exchanges.js. The fix must be applied in the generator template, not the generated file, otherwise it will be overwritten on the nextnpm run generate:sdk:all.Suggested Fix
In the generator template, replace
Optional[Any]with a concrete type forsignature_type:If the full set of valid values is not stable enough to
Literal-ize,Optional[str]is still a strict improvement overOptional[Any].Found by automated Python type hints audit