Skip to content

arguments attribute of inspect.BoundArguments should be annotated as dict instead of OrderedDict #15832

@prasanthcakewalk

Description

@prasanthcakewalk

The arguments attribute of inspect.BoundArguments is of type dict in the stdlib, but typeshed has it annotated as OrderedDict[str, Any]:

Relevant code-blocks from cpython:

Relevant code-block from typeshed:

typeshed/stdlib/inspect.pyi

Lines 469 to 481 in df45287

class BoundArguments:
__slots__ = ("arguments", "_signature", "__weakref__")
arguments: OrderedDict[str, Any]
@property
def args(self) -> tuple[Any, ...]: ...
@property
def kwargs(self) -> dict[str, Any]: ...
@property
def signature(self) -> Signature: ...
def __init__(self, signature: Signature, arguments: OrderedDict[str, Any]) -> None: ...
def apply_defaults(self) -> None: ...
def __eq__(self, other: object) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]

Relevant section of the documentation: https://docs.python.org/3/library/inspect.html#inspect.BoundArguments.arguments

Proposed fix:

  • Change OrderedDict[str, Any] to dict[str, Any] in lines 471 and 478 of inspect.pyi.
  • Remove OrderedDict import from inspect.pyi,

If this is acceptable, I can create a PR implementing these changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    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