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

Better support for typing_extensions module #2413

Closed
Zac-HD opened this issue Apr 27, 2020 · 0 comments · Fixed by #2417
Closed

Better support for typing_extensions module #2413

Zac-HD opened this issue Apr 27, 2020 · 0 comments · Fixed by #2417
Assignees
Labels
enhancement it's not broken, but we want it to be better

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Apr 27, 2020

The typing_extensions module "contains both backports of new types added to the typing module, as well as experimental types that will eventually be added to the typing module".

What makes this relevant to us is that we have a bunch of internal code that looks for these types specifically in the typing module, e.g.:

def is_typing_literal(thing):
return (
hasattr(typing, "Literal")
and getattr(thing, "__origin__", None) == typing.Literal
)

So if you're using typing.Literal in Python 3.8, that works. But if you're using typing_extensions.Literal in Python 3.7 - or 3.8 for compatibility - you're out of luck.

Going through and inserting checks to handle typing_extensions would improve our inference support for projects like LibCST - I found this while working on an extension to Zac-HD/hypothesmith#2, but obviously it's a generally useful feature.

The main cost will be setting up tests for another optional integration to check that our non-typing_extensions-specific features work whether it's installed or not, that they work when installed, and ideally that we don't import it if it's not already in use.

@Zac-HD Zac-HD added the enhancement it's not broken, but we want it to be better label Apr 27, 2020
@Zac-HD Zac-HD self-assigned this Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement it's not broken, but we want it to be better
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant