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

TypedDict silently accepts experimental PEP 728 arguments but ignores them #9928

Open
decorator-factory opened this issue Feb 17, 2025 · 0 comments
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working

Comments

@decorator-factory
Copy link

decorator-factory commented Feb 17, 2025

For completely unknown TypedDict kwargs, pyright correctly shows an error:

class Foo(TypedDict, bar=True):
    #                ^^^^^^^^
    # TypedDict does not support __init_subclass__ parameter "bar
    x: int

However, it does not complain about closed and extra_items, even if enableExperimentalFeatures is not enabled.

from typing import TypedDict

class HasX(TypedDict, closed=True):  # no error reported
    x: int

class HasXY(TypedDict):
    x: int
    y: int

has_xy: HasXY = {"x": 1, "y": 2}
has_x: HasX = has_xy  # assignment is allowed

(the assignment is disallowed when enableExperimentalFeatures is on)

It makes it seem like these flags are supported, but they are silently ignored. I expected an error message like

PEP 728 support is experimental. Set enableExperimentalFeatures to true to enable it


Pyright version: 1.1.394

Python version: 3.12

@decorator-factory decorator-factory added the bug Something isn't working label Feb 17, 2025
erictraut added a commit that referenced this issue Feb 17, 2025
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants