Skip to content

wrong positional-or-keyword information in Mapping and MutableMapping #13432

@beauxq

Description

@beauxq

Mapping and MutableMapping information for get and pop says that the default parameter is positional or keyword.

dict says positional only, and that is correct at runtime.

So this type checks with no errors, but crashes with TypeError:

from collections.abc import Mapping, MutableMapping


def foo(x: MutableMapping[str, int]) -> int:
    return x.pop("3", default=3)


foo({})  # crash: TypeError: dict.pop() takes no keyword arguments


def goo(x: Mapping[str, int]) -> int:
    return x.get("3", default=3)


goo({})  # crash: TypeError: dict.get() takes no keyword arguments


# same with MutableMapping.get

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