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

Handle Python 3.9 _SpecialGenericAlias #69

Merged
merged 2 commits into from
Mar 21, 2021

Conversation

bnavigator
Copy link
Contributor

@bnavigator bnavigator commented Mar 21, 2021

Another take at #66 which keeps compatibility with older Python versions.

Fixes #60

@bnavigator
Copy link
Contributor Author

See https://github.com/bnavigator/typing_inspect/runs/2159879881 for a sucessful Travis CI run on Python 3.9 when #68 and #69 are combined.

Comment on lines 463 to 464
if isinstance(tp, typingGenericAlias):
res = tp.__args__
Copy link
Contributor Author

Choose a reason for hiding this comment

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

From libcst test suite:

[  133s] ERROR: test_basic_pass_19 (libcst.tests.test_type_enforce.TypeEnforcementTest)
[  133s] ----------------------------------------------------------------------
[  133s] Traceback (most recent call last):
[  133s]   File "/home/abuild/rpmbuild/BUILD/libcst-0.3.16/libcst/testing/utils.py", line 90, in new_test
[  133s]     return member(self, *data)
[  133s]   File "/home/abuild/rpmbuild/BUILD/libcst-0.3.16/libcst/tests/test_type_enforce.py", line 141, in test_basic_pass
[  133s]     is_value_of_type(value, expected_type),
[  133s]   File "/home/abuild/rpmbuild/BUILD/libcst-0.3.16/libcst/_type_enforce.py", line 146, in is_value_of_type
[  133s]     type_args = get_args(expected_type, evaluate=True)
[  133s]   File "/usr/lib/python3.9/site-packages/typing_inspect.py", line 436, in get_args
[  133s]     res = tp.__args__
[  133s]   File "/usr/lib64/python3.9/typing.py", line 694, in __getattr__
[  133s]     raise AttributeError(attr)
[  133s] AttributeError: __args__

@ilevkivskyi ilevkivskyi merged commit 6bc521b into ilevkivskyi:master Mar 21, 2021
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.

is_generic_type(List) is False in 3.9
2 participants