-
-
Notifications
You must be signed in to change notification settings - Fork 120
allow TypedDict as a type argument #614
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one thing that would make this code a bit clearer is if we had a custom copy of _SpecialForm
(that isn't recognized as such by the code typing.py
, maybe called something like _UnrecognizedSpecialForm
and documented) and derive from that. This would also make it easier to keep that "fake" special form in sync with the real typing._SpecialForm
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already vendor typing._SpecialForm
here:
typing_extensions/src/typing_extensions.py
Lines 2204 to 2205 in b07d245
# Vendored from cpython typing._SpecialFrom | |
class _SpecialForm(typing._Final, _root=True): |
If I move that higher up in the file (so it's defined before _TypedDictSpecialForm
) and then make a one-line change so that _TypedDictSpecialForm
inherits from _SpecialForm
rather than _ExtensionsSpecialForm
, all our tests pass and it fixes the issue reported.
This is what we already do to ensure that typing.Type[typing_extensions.Self]
is accepted on older versions of Python.
Could you also add a comment that this means that this |
Thank you! I missed that we already had a |
I tried some more creative solutions but couldn't get anything more concise to work.
Fixes #613.