-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
In typing docs, note explicit import needed for IO and Pattern/Match #82533
Comments
Hello! In https://github.com/python/cpython/blob/master/Lib/typing.py#L115-L117, there is a note about the io and re classes not being included in typing.all. I am a relatively new user of typing, and I did Reading through the typing source, it's clear that this was an intentional decision. So, instead of reporting a bug, I'd like to request a documentation enhancement! The docs for typing make no mention of typing.io or typing.re. So, my request is: In the sections for the IO/TextIO/BinaryIO and Pattern/Match classes, include text warning the user that these types are not imported when you do |
I don't think this should really be a warning, probably just a note, but otherwise I totally agree. Would you like to make a PR? |
Shadowing the real modules from typing import * would indeed be bad, but that argument IMHO doesn't hold for the types |
Wait, is the OP maybe that there’s a difference between typeshed an the stdlib typing.py? |
It turns out that IO, TextIO, BinaryIO, Match, and Pattern aren't in typing.__all__. As Walter points out above, there's no clear reason for this. I am submitting a PR to add them to __all__. |
Fix merged to main (3.11), 3.10, and 3.9. Not applicable to older Pythons as they are security fixes only. |
@Łukasz thanks for your merging spree! I'm actually not sure this should go into 3.9. Seems potentially dangerous that people upgrading from an earlier 3.9 patch release will now see new names injected into their namespace if they do |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: