Skip to content

[python-types] errors.py: 3 exception __init__ methods missing -> None return type #731

@realfishsam

Description

@realfishsam

File

sdks/python/pmxt/errors.py

Missing Return Types

Three exception constructors are missing -> None. PEP 484 requires __init__ to carry an explicit return type.

Line 16 — PmxtError.__init__ (HIGH — base class for all SDK errors)

def __init__(self, message: str, code: str = "UNKNOWN_ERROR", retryable: bool = False, exchange: str | None = None):

PmxtError is the root exception that users catch with except PmxtError. Missing -> None on the base class propagates the gap to every subclass that does not define its own __init__.

Line 70 — RateLimitExceeded.__init__ (HIGH — public exception)

def __init__(self, message: str, retry_after: int | None = None, **kwargs):
  • Missing -> None
  • **kwargs is entirely untyped — it is forwarded to super().__init__(**kwargs), where it accepts code, retryable, exchange. A TypedDict or explicit keyword parameters would allow static validation of callers.

Line 88 — ValidationError.__init__ (HIGH — public exception)

def __init__(self, message: str, field: str | None = None, **kwargs):
  • Missing -> None
  • Same untyped **kwargs concern as RateLimitExceeded.

Impact

Suggested Fix

# Line 16
def __init__(self, message: str, code: str = "UNKNOWN_ERROR", retryable: bool = False, exchange: Optional[str] = None) -> None:

# Line 70
def __init__(self, message: str, retry_after: Optional[int] = None, code: str = "UNKNOWN_ERROR", retryable: bool = False, exchange: Optional[str] = None) -> None:

# Line 88
def __init__(self, message: str, field: Optional[str] = None, code: str = "UNKNOWN_ERROR", retryable: bool = False, exchange: Optional[str] = None) -> None:

Explicit keyword parameters instead of **kwargs also eliminate the untyped kwargs concern.


Found by automated Python type hints audit

Metadata

Metadata

Assignees

No one assigned

    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