-
Notifications
You must be signed in to change notification settings - Fork 105
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
Only use typing-extensions if necessary #563
base: master
Are you sure you want to change the base?
Only use typing-extensions if necessary #563
Conversation
TypeAlias was included in the typing module in Python 3.10. Self was included in the typing module in Python 3.11.
Reviewer's Guide by SourceryThis pull request refactors the import logic for type annotations so that the usage of typing-extensions is conditional based on the Python version. The changes conditionally import Self and TypeAlias from either typing or typing-extensions depending on the Python version, reducing unnecessary dependencies when running on newer Python versions. No diagrams generated as the changes look simple and do not need a visual representation. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @ppentchev - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding a comment explaining why the version check is different for
Self
andTypeAlias
. - It might be cleaner to define a helper function to handle the conditional import of
Self
andTypeAlias
.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
As discussed in #562 - a second PR that contains the change that makes the use of typing-extensions conditional on the Python version.
Thanks for your work on libtmux and tmuxp!
Summary by Sourcery
Enhancements:
typing.Self
if Python version is greater than or equal to 3.11, otherwise import it fromtyping_extensions
.