File
sdks/python/pmxt/client.py
Note: This is an addendum to #227, which covers params: Optional[dict] and other issues in the same file. These findings were not included there.
Excessive Any — Router Proxy Methods Return List[Any] (CRITICAL)
The Exchange base class exposes 9 router-related methods that return List[Any]. The Router subclass properly overrides these with concrete types, but the base class is the declared type for every exchange instance. Users who call these methods on Polymarket, Kalshi, etc. (which do not override them) get List[Any] — no IDE completion on results.
| Line |
Method |
Current return |
Should be |
| 1135 |
fetch_market_matches |
List[Any] |
List[MatchResult] |
| 1158 |
fetch_matches |
List[Any] |
List[MatchResult] |
| 1180 |
fetch_event_matches |
List[Any] |
List[EventMatchResult] |
| 1203 |
compare_market_prices |
List[Any] |
List[PriceComparison] |
| 1225 |
fetch_related_markets |
List[Any] |
List[MatchResult] |
| 1247 |
fetch_matched_markets |
List[Any] |
List[MatchResult] |
| 1270 |
fetch_matched_prices |
List[Any] |
List[PriceComparison] |
| 1293 |
fetch_hedges |
List[Any] |
List[PriceComparison] |
| 1315 |
fetch_arbitrage |
List[Any] |
List[ArbitrageOpportunity] |
All model classes (MatchResult, EventMatchResult, PriceComparison, ArbitrageOpportunity) are already imported from .models at the top of client.py.
Untyped callback Parameter — Watch Methods (HIGH)
Three watch methods accept callback: Optional[Any]. The callback parameter is not documented as to what signature it should have, making it impossible for users to know what function to pass, and for type checkers to validate call sites.
| Line |
Method |
Parameter issue |
| 2143 |
watch_prices(self, market_address: str, callback: Optional[Any] = None) -> Any |
callback untyped; return type Any |
| 2179 |
watch_user_positions(self, callback: Optional[Any] = None) -> List[Position] |
callback untyped |
| 2216 |
watch_user_transactions(self, callback: Optional[Any] = None) -> Any |
callback untyped; return type Any |
Impact
- Every caller of the 9 router proxy methods on any non-Router exchange gets
Any back — zero IDE autocompletion on results.
watch_prices and watch_user_transactions return Any, leaving the full shape of streaming payloads invisible to type checkers.
callback being Optional[Any] means IDEs cannot validate whether a user-supplied callback has the right signature.
Suggested Fix
Router proxy methods
from .models import MatchResult, EventMatchResult, PriceComparison, ArbitrageOpportunity # already imported
def fetch_market_matches(self, params: Optional[Dict[str, Any]] = None, **kwargs) -> List[MatchResult]: ...
def fetch_event_matches(self, params: Optional[Dict[str, Any]] = None, **kwargs) -> List[EventMatchResult]: ...
def compare_market_prices(self, params: Dict[str, Any], **kwargs) -> List[PriceComparison]: ...
def fetch_hedges(self, params: Dict[str, Any], **kwargs) -> List[PriceComparison]: ...
def fetch_arbitrage(self, params: Optional[Dict[str, Any]] = None, **kwargs) -> List[ArbitrageOpportunity]: ...
# etc.
Watch methods
from typing import Callable
def watch_prices(
self,
market_address: str,
callback: Optional[Callable[[Dict[str, Any]], None]] = None,
) -> Dict[str, Any]: ...
def watch_user_transactions(
self,
callback: Optional[Callable[[Dict[str, Any]], None]] = None,
) -> Dict[str, Any]: ...
Found by automated Python type hints audit
File
sdks/python/pmxt/client.pyExcessive
Any— Router Proxy Methods ReturnList[Any](CRITICAL)The
Exchangebase class exposes 9 router-related methods that returnList[Any]. TheRoutersubclass properly overrides these with concrete types, but the base class is the declared type for every exchange instance. Users who call these methods onPolymarket,Kalshi, etc. (which do not override them) getList[Any]— no IDE completion on results.fetch_market_matchesList[Any]List[MatchResult]fetch_matchesList[Any]List[MatchResult]fetch_event_matchesList[Any]List[EventMatchResult]compare_market_pricesList[Any]List[PriceComparison]fetch_related_marketsList[Any]List[MatchResult]fetch_matched_marketsList[Any]List[MatchResult]fetch_matched_pricesList[Any]List[PriceComparison]fetch_hedgesList[Any]List[PriceComparison]fetch_arbitrageList[Any]List[ArbitrageOpportunity]All model classes (
MatchResult,EventMatchResult,PriceComparison,ArbitrageOpportunity) are already imported from.modelsat the top ofclient.py.Untyped
callbackParameter — Watch Methods (HIGH)Three watch methods accept
callback: Optional[Any]. Thecallbackparameter is not documented as to what signature it should have, making it impossible for users to know what function to pass, and for type checkers to validate call sites.watch_prices(self, market_address: str, callback: Optional[Any] = None) -> Anycallbackuntyped; return typeAnywatch_user_positions(self, callback: Optional[Any] = None) -> List[Position]callbackuntypedwatch_user_transactions(self, callback: Optional[Any] = None) -> Anycallbackuntyped; return typeAnyImpact
Anyback — zero IDE autocompletion on results.watch_pricesandwatch_user_transactionsreturnAny, leaving the full shape of streaming payloads invisible to type checkers.callbackbeingOptional[Any]means IDEs cannot validate whether a user-supplied callback has the right signature.Suggested Fix
Router proxy methods
Watch methods
Found by automated Python type hints audit