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

Can't call get on an empty dict #17684

Open
0e4ef622 opened this issue Aug 16, 2024 · 0 comments · May be fixed by #18273
Open

Can't call get on an empty dict #17684

0e4ef622 opened this issue Aug 16, 2024 · 0 comments · May be fixed by #18273
Labels
bug mypy got something wrong

Comments

@0e4ef622
Copy link

Bug Report

Mypy complains when I try to call get on an empty dict.

To Reproduce

x = {}.get("x")

Expected Behavior

No error.

Actual Behavior

a.py:1: error: No overload variant of "get" of "dict" matches argument type "str"  [call-overload]
a.py:1: note: Possible overload variants:
a.py:1: note:     def get(self, Never, /) -> None
a.py:1: note:     def get(self, Never, Never, /) -> Never
a.py:1: note:     def [_T] get(self, Never, _T, /) -> _T
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 1.11.1
  • Python version used: 3.12.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant