-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
PEP 655 (Required TypedDict items) tracker #6301
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
Comments
I feel like we should also wait for the PEP to be accepted. typing-extensions can include experimental features that may be rejected, but typeshed should not. |
This is now fully supported in mypy. |
I think it supports only one of Required and NotRequired? That's what the initial PR said but I haven't verified with the release. |
Quick tests confirms that it works with both: from typing_extensions import TypedDict, Required, NotRequired
class NonTotal(TypedDict, total=False):
foo: int
bar: Required[str]
nt1: NonTotal = {"foo": 123, "bar": ""}
nt2: NonTotal = {"foo": "", "bar": 123} # incompatible types
nt3: NonTotal = {"foo": 123} # missing key "bar"
nt4: NonTotal = {"bar": ""}
class Total(TypedDict, total=True):
foo: int
bar: NotRequired[str]
t1: Total = {"foo": 123, "bar": ""}
t2: Total = {"foo": "", "bar": 123} # incompatible types
t3: Total = {"bar": ""} # missing key "foo"
t4: Total = {"foo": 123} |
Hello @srittau, just to let you know you can check the "PEP accepted" checkbox, see https://groups.google.com/g/dev-python/c/odKM_OpDES0 and https://peps.python.org/pep-0655/ |
Thanks, done! |
I've used Also cc @pradeep90 and @shannonzhu: Does pyre support |
@srittau No, we don't yet support |
Available in PyCharm >= 2022.2 EAP 4 https://youtrack.jetbrains.com/issue/PY-53611/Support-PEP-655-typingRequiredtypingNotRequired-for-TypedDicts |
Added support in Pyre v0.9.15. |
Since the pytype checks run against the zxcvbn stubs, which already use |
This issue is supposed to track when we can start to use
Required
/NotRequired
(PEP 655) in typeshed. Support is needed in released versions of:The text was updated successfully, but these errors were encountered: