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

Typing spec update: ClassVar and Final within TypedDict #39

Closed
5 tasks done
InSyncWithFoo opened this issue Dec 1, 2024 · 1 comment
Closed
5 tasks done

Typing spec update: ClassVar and Final within TypedDict #39

InSyncWithFoo opened this issue Dec 1, 2024 · 1 comment
Labels

Comments

@InSyncWithFoo
Copy link

InSyncWithFoo commented Dec 1, 2024

As discussed in the thread linked above, major type checkers currently don't consider such a ClassVar an error.

As for Final, Pyright and Mypy do reports it, but their messages are unclear; Pytype and Pyre, on the other hand, ignores such items completely:

(playgrounds: Pyright, Mypy, Pyre)

class TD(TypedDict):
    v: ClassVar[int]     # all     => fine

    f: Final[int]        # pyright => error: "f" is declared Final, but value is not assigned
                         # mypy    => error: Final can be only used as an outermost qualifier in a variable annotation
                         # pyre    => fine
                         # pytype  => fine

    a: Final[int] = 42   # pyright => error: TypedDict classes can contain only type annotations
                         # mypy    => error: Right hand side values are not supported in TypedDict
                         # pyre    => fine
                         # pytype  => fine

Reference implementation: None.

TC Sign-off

  • Carl
  • Eric
  • Jelle
  • Jukka
  • Rebecca
@InSyncWithFoo
Copy link
Author

I'm closing this as the PR has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants