-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
make os._wrap_close not inherit from TextIOWrapper #12774
Conversation
Methods are passed through at runtime via __getattr__ related to python#3968
We could also consider leaving some of the methods out of the stubs since the full scope of what's available on
|
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
I've kept thinking about this one, and the more I think about it the more it seems like picking only a subset of TextIOWrapper's methods to put in the stubs seems like a reasonable idea. If anyone else has thoughts on that, I'd love to hear them. |
mypy-primer revealed only I'm not too surprised - the primary use of os.popen probably happens in smaller scripts than what make it into mypy-primer's corpus. |
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.
I'm fine with proxying all methods, but if you want to go for a smaller subset (at least until someone complains), I'm fine with that, too.
I looked through the first five pages of github code search results for Let's go with the smaller subset to start and see if anyone notices. I updated to include the |
This comment has been minimized.
This comment has been minimized.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Methods are passed through at runtime via
__getattr__
related to #3968
I think is more correct, but we may be getting into territory where duplication of effort becomes a question. Is getting the inheritance right worth maintaining the extra lines of code in this case?
I could see no reason why TextIOWrapper was imported as _TextIOWrapper, other than that import is extremely old; I didn't check but I suspect the current rules around
as
imports were not as established at the time, and the underscore was added to prevent it appearing in os's namespace. I normalized to just a normal import for that reason.