Skip to content

Conversation

@RA80533
Copy link
Contributor

@RA80533 RA80533 commented Apr 24, 2023

Python 3.9.1 changed the type() of Literal instances to be _LiteralGenericAlias instead of _GenericAlias.

is_literal_type() assumed the change took place in Python 3.9.0 and checked for it accordingly. Because the assumption was incorrect, it failed to detect Literal types in Python versions [3.9.0, 3.9.1).

  • is_literal_type() was changed to check PY_310_MIN instead of PY_39_MIN (and check for PY_39 separately)
  • test_is_literal_unsupported_python() was updated to mock the updated conditions
  • test_is_literal_py39() was added to test backwards compatibility for Python versions [3.9.0, 3.9.1)

Fixes #103

@RA80533 RA80533 requested a review from Fatal1ty April 24, 2023 18:40
Copy link
Owner

@Fatal1ty Fatal1ty left a comment

Choose a reason for hiding this comment

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

LGTM. Can you squash and force push all the commits as one to retain you as an author before the merge?

Python 3.9.1 changed the `type()` of `Literal` instances to be
`_LiteralGenericAlias` instead of `_GenericAlias`.

`is_literal_type()` assumed the change took place in Python 3.9.0 and
checked for it accordingly. Because the assumption was incorrect, it
failed to detect `Literal` types in Python versions [3.9.0, 3.9.1).

This commit changes `is_literal_type()` to check `PY_310_MIN` instead of
`PY_39_MIN` to fix the issue.
@RA80533 RA80533 force-pushed the fix/literal-support branch from 7b45d93 to aba3857 Compare April 24, 2023 19:24
@Fatal1ty Fatal1ty merged commit b99a1f6 into Fatal1ty:master Apr 24, 2023
@Fatal1ty
Copy link
Owner

Thanks 👍

@RA80533 RA80533 deleted the fix/literal-support branch April 25, 2023 17:01
@fabiopedrosa
Copy link

@Fatal1ty can we get this fix into a release please?

@Fatal1ty
Copy link
Owner

Fatal1ty commented Jun 5, 2023

@fabiopedrosa Can it wait a bit more? I'm planning to make a release this or next week after finishing the following issues:

Good news is I'm almost done with the first two, just need to update the documentation.

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.

typing.Literal isn't supported properly on Python 3.9.0

3 participants