-
Notifications
You must be signed in to change notification settings - Fork 35
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
Fix for Python 3.9+. #66
Conversation
Fixes <ilevkivskyi#60>. Based on an idea in ilevkivskyi#60 (comment).
Not sure if that's the most correct fix (probably not, I haven't spent much time on it), but it at least allows the test suite to pass. |
@@ -75,7 +75,7 @@ def is_generic_type(tp): | |||
""" | |||
if NEW_TYPING: | |||
return (isinstance(tp, type) and issubclass(tp, Generic) or | |||
isinstance(tp, _GenericAlias) and | |||
(isinstance(tp, _GenericAlias) or isinstance(tp, _SpecialGenericAlias)) and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: isinstance
accepts tuples of types and isinstance(tp, (_GenericAlias, _SpecialGenericAlias))
could be easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Few comments:
- Please use a tuple of types in
isinstance()
as @jstasiak suggested. - You should import
_SpecialGenericAlias
conditionally on Python version, otherwise tests will fail on other Python versions. - There are dozen other places in the module where
_GenericAlias
is used, should they also be updated? - It looks like this only change in itself is not sufficient to fix test failures on Python 3.9, as you can see from a build I started, there is also some error about TypedDict keys.
Weird! Perhaps because I used the last 0.6.0 PyPI archive instead of the latest commit? Here it gave:
The package definition I used in Guix reads as: (define-public python-typing-inspect
(package
(name "python-typing-inspect")
(version "0.6.0")
(source (origin
(method url-fetch)
(uri (pypi-uri "typing_inspect" version))
(sha256
(base32
"1dzs9a1pr23dhbvmnvms2jv7l7jk26023g5ysf0zvnq8b791s6wg"))
(patches (search-patches "python-typing-inspect-fix.patch"))))
(build-system python-build-system)
(propagated-inputs
`(("python-mypy-extensions" ,python-mypy-extensions)
("python-typing-extensions" ,python-typing-extensions)))
(home-page "https://github.com/ilevkivskyi/typing_inspect")
(synopsis "API for inspection of types in the Python @code{typing} module")
(description
"The @code{typing_inspect} module defines experimental API for runtime
inspection of types defined in the Python standard typing module.")
(license license:expat))) As you can see if fetches its sources from the PyPI release 0.6.0 release. |
Answering myself: yes, this patch fixes the issues when using the last release 0.6.0, but is not sufficient for what's in master ( |
This patch makes build for Python < 3.9 fail for me. |
@Apteryks Sorry, closing this in favor of the other PRs, thanks for your attempt! |
Fixes #60.
Based on an idea in
#60 (comment).