-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Inconsistent type inference between open() and Path().open() #2911
Comments
Literal types are not supported currently, see #2913. Using |
Thanks Sebastian - Should we leave this open until literal types are supported? Regards, Larry |
I added the inexpressable tag. We can leave it open so it can be fixed later. |
Literal types are now supported. Patches welcome! |
I'll pull something together in a while - as I'm still a relative python novice, does the typeshed have a style guide (or ideally, something I can refer to as an acceptable style for implementing literal type lookups?). |
Our CONTRIBUTING.md has a couple of style guidelines. For Literals specifically, we're in mostly uncharted territory, though I think we just merged one PR adding Literals. |
I have run into an issue with inconsistent type-inferences for open() and pathlib.Path().open().
I've previously raised this as possible mypy bug #6666. In response to this gvanrossum advised:
So I am re-raising this issue here. The following snippet demonstrates the issue.
yields:
However, running mypy reveal_type on fp and fp1 yields:
I would expect both of these to reveal typing.TextIO. I found this issue when using a routine that switched TextIO output between sys.stdout (TextIO) and a file opened with Path().open() (IO).
This is on python 3.7.2 and mypy 0.700.
I'm happy to develop a PR on this, but it will be a while before I get started and given I've got a bit of learning curve, probably a while longer before I finish. I'm assuming this shouldn't be an issue given I couldn't find any other references to this problem in several hours of combing github issues and the web in general.
The text was updated successfully, but these errors were encountered: