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

(🐞) Check __setitem__ and __getitem__ for TypedDicts #12270

Open
KotlinIsland opened this issue Mar 2, 2022 · 1 comment
Open

(🐞) Check __setitem__ and __getitem__ for TypedDicts #12270

KotlinIsland opened this issue Mar 2, 2022 · 1 comment

Comments

@KotlinIsland
Copy link
Contributor

from typing import TypedDict

class A(TypedDict):
    x: int
a: A
a.__setitem__('x', '')  # no error
b: int = a.__getitem__('x')  # error: Incompatible types in assignment (expression has type "object", variable has type "int")
@KotlinIsland KotlinIsland added the bug mypy got something wrong label Mar 2, 2022
@KotlinIsland KotlinIsland changed the title check __setitem__ and __getitem__ for TypedDicts (🐞) Check __setitem__ and __getitem__ for TypedDicts Mar 2, 2022
@jhance
Copy link
Collaborator

jhance commented Mar 9, 2022

What is the purpose of supporting this? How often do people really use foo.__getitem__("x") instead of foo["x"]?

@jhance jhance added feature and removed bug mypy got something wrong labels Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants