Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
beauxq opened this issue Jan 24, 2025 · 0 comments
Open

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

beauxq opened this issue Jan 24, 2025 · 0 comments

Comments

@beauxq
Copy link

beauxq commented Jan 24, 2025

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant