Skip to content

[python-types] ws_client.py: 2 __init__ methods missing -> None return type #691

@realfishsam

Description

@realfishsam

File

sdks/python/pmxt/ws_client.py

Missing Return Types

  • Line 23: def __init__(self, request_id: str, method: str, symbols: List[str]): → should be -> None
  • Line 39: def __init__(self, host: str, access_token: Optional[str] = None, api_key: Optional[str] = None): → should be -> None

Both are __init__ methods — PEP 484 and mypy require them to be explicitly annotated -> None. Without it, disallow_untyped_defs = true (tracked in issue #246) will reject them when enforced.

Impact

  • HIGH: SidecarWsClient (line 39) is instantiated by every call to Exchange.watch_order_book() and Exchange.watch_order_books(). IDEs that read annotations to provide hover-docs for __init__ will show incomplete information.
  • HIGH: _WsSubscription (line 23) is an internal helper, but its constructor is called in every subscribe path.

Suggested Fix

# Line 23
class _WsSubscription:
    def __init__(self, request_id: str, method: str, symbols: List[str]) -> None:
        ...

# Line 39
class SidecarWsClient:
    def __init__(self, host: str, access_token: Optional[str] = None, api_key: Optional[str] = None) -> None:
        ...

Found by automated Python type hints audit

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions