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

False positive warning when poping from a open TypedDict #9805

Open
Daraan opened this issue Feb 3, 2025 · 0 comments
Open

False positive warning when poping from a open TypedDict #9805

Daraan opened this issue Feb 3, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Daraan
Copy link

Daraan commented Feb 3, 2025

Describe the bug
I am using dict.pop(key, default) to remove an extra item from a TypedDict this results in an unexpected error, that seems wrong: I think pop misses an overload for a simple str in this case.
Pylance shows all provided keys from the TypedDict in the signature.

error: No overloads for "pop" match the provided arguments
error: Argument of type "Literal['poped_key']" cannot be assigned to parameter "k" of type "Literal['some_present_key']" in function "pop"
  "Literal['poped_key']" is not assignable to type "Literal['some_present_key']"

Code or Screenshots
Code sample in pyright playground

from typing_extensions import TypedDict, Required, NotRequired, Any, TypeAlias

class A(TypedDict, total=False, closed=False):
    foo: float
    

def get_A() -> A: ...

a = get_A()

a.pop("somekey", None)

VS Code extension or command-line
pyright 1.1.393

@Daraan Daraan added the bug Something isn't working label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant