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_extensions.pyi imports Protocol from typing.pyi rather than defining its own #7130

Closed
erictraut opened this issue Feb 4, 2022 · 2 comments

Comments

@erictraut
Copy link
Contributor

Until recently, typing_extensions.pyi declared its own Protocol symbol as follows:

Protocol: _SpecialForm = ...

It now directly imports Protocol from typing.pyi and re-exports this symbol. This means pyright can no longer differentiate between the two symbols. There's an important difference because typing.Protocol will generate a runtime exception if used in versions of Python prior to 3.7, but typing_extensions.Protocol will not.

@JelleZijlstra, is there a reason this change was made? Or put another way, is there a reason not to change it back?

Here's a link to bug that describes the regression in pyright: microsoft/pyright#2987

@JelleZijlstra
Copy link
Member

I'm ok with changing this back; there wasn't really a compelling reason to merge the two.

@AlexWaygood
Copy link
Member

Apologies for causing the regression @erictraut (it was my PR IIRC).

Seems like it should be added back to typing_extensions along with a comment explaining why it's duplicated there from typing rather than being re-exported, even though it's available in typing unconditionally (from typeshed's POV — at runtime, it obviously can only be imported from typing in 3.8+).

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

No branches or pull requests

4 participants