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

Support Literal (PEP 586) #39

Merged
merged 6 commits into from Jul 3, 2019
Merged

Support Literal (PEP 586) #39

merged 6 commits into from Jul 3, 2019

Conversation

bgw
Copy link
Contributor

@bgw bgw commented Jul 2, 2019

Adds an is_literal_type API, and fixes get_args for literal types on 3.6 and 2.7 (provided by typing_extensions).

This feature is in 3.8, but it's available as a backport to 3.7 and below as part of typing_extensions, so this adds typing_extensions as a dependency.

I've tested this pull request by running the unit tests against Python 2.7, 3.6, and 3.7.

Adds an `is_literal_type` API, and fixes `get_args` for literal types on
3.6 and 2.7 (provided by typing_extensions).

This feature is in 3.8, but it's available as a backport to 3.7 and
below as part of `typing_extensions`, so this adds `typing_extensions`
as a dependency.

I've tested this pull request by running the unit tests against Python
2.7, 3.6, and 3.7.
Copy link

@jimmylai jimmylai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Owner

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for PR! Looks good.

@ilevkivskyi
Copy link
Owner

I am going to close and re-open to trigger Travis build with new master.

@ilevkivskyi ilevkivskyi closed this Jul 3, 2019
@ilevkivskyi ilevkivskyi reopened this Jul 3, 2019
@ilevkivskyi ilevkivskyi merged commit 5266802 into ilevkivskyi:master Jul 3, 2019
@bgw bgw mentioned this pull request Sep 27, 2019
@anntzer
Copy link
Contributor

anntzer commented Aug 28, 2021

It looks like this missed adding a check in get_origin as well to make get_origin(Literal["a"]) == Literal? (similar to the one in get_args)

@ilevkivskyi
Copy link
Owner

@anntzer Yes, the origin should be Literal, please feel free to send a PR.

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

Successfully merging this pull request may close these issues.

None yet

4 participants