Description
Hello
While the issue I describe is a very weird phenomenon that's not directly related to typing_extensions, I would like to propose a solution that might be able to solve this.
Note: this is an issue related to python <=3.10
Minimal reproducable example
import typing
print(hasattr(typing, "Self"))
import PySide6 # noqa
print(hasattr(typing, "Self"))
This prints:
False
True
In other words, PySide6
manipulates python's built-in typing module.
Observation
Examining typing_extension.py
, I found this section
typing_extensions/src/typing_extensions.py
Lines 2277 to 2281 in 59d2c20
Proposal
Would it make sense to check sys.version_info
instead of checking the existance of Self
attribute?
This is already done in several places, e.g.:
typing_extensions/src/typing_extensions.py
Lines 192 to 196 in 59d2c20
IMHO it looks like a more robust solution (that can solve this specific problem)
I would love to hear your thoughts. I'd be happy to open a PR if needed.
Thanks!