Skip to content

Why is collections.ChainMap.__missing__ defined in the stub? #7188

Closed
@AlexWaygood

Description

@AlexWaygood

collections.ChainMap.__missing__ is defined in typeshed here:

def __missing__(self, __key: _KT) -> _VT: ...

But, at runtime, it always raises KeyError (and always has done), so there's no situation in which it would be safe to call this method (it's really just an implementation detail to give ChainMap a nicer error message for when the key isn't present in any of the underlying mappings, as far as I can tell).

The method was added to typeshed in a standalone PR (#4784)... Am I __missing__ something? Is there a good reason for it to be there?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions