You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Self being a typing._SpecialForm prevents a case from PEP 673 #26
Yes, vendoring would be the way to go. The place where this throws lets things it doesn't recognize through, so if we just make Self look like an unrelated object, it should pass.
This is an issue with mypy not yet fully supporting typing_extensions.Self, you might be interested in python/mypy#13133, the runtime works as expected
Activity
Gobot1234 commentedon Nov 25, 2021
Hi, I'm not entirely sure what can be done here until the PEP is accepted and I can change https://github.com/python/cpython/blob/e0f8a3e9b96bbc2597f61be96993ef0c768a19fe/Lib/typing.py#L176 to
If you have any suggestions for how to fix this now, I'd be more than happy to implement them.
However, if you need this to work right now you you have a few options:
typing_extensions.TypeAliasand__future__.annotationsor stringify the types).JelleZijlstra commentedon Nov 25, 2021
We can probably fudge things in typing-extensions so that it's not an instance of
_SpecialForm.CharString commentedon Nov 26, 2021
@Gobot1234 Yes, for my use case I'm using a string as ForwardRef now. I just wondered if I were doing something wrong.
@JelleZijlstra Like vendoring the _SpecialForm from the cpython 3.11 codebase? Or a more elegant fudge? Namespaces are one honking great idea :-)
JelleZijlstra commentedon Nov 26, 2021
Yes, vendoring would be the way to go. The place where this throws lets things it doesn't recognize through, so if we just make Self look like an unrelated object, it should pass.
Vendor typing._SpecialForm to fool typing._type_check
CharString commentedon Nov 26, 2021
Something like this?
Vendor typing._SpecialForm to fool typing._type_check
Vendor typing._SpecialForm to fool typing._type_check (#966)
Vendor typing._SpecialForm to fool typing._type_check (python#966)
ikamensh commentedon Aug 9, 2022
This still happens with
typing_extensions == 4.3.0:Gobot1234 commentedon Aug 9, 2022
This is an issue with mypy not yet fully supporting typing_extensions.Self, you might be interested in python/mypy#13133, the runtime works as expected