-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
BytesIO.name and StringIO.name should not be defined #1790
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
Comments
Ow, this cuts deep. It seems class |
A previous issue that discussed |
Rather than trying to fix the deep issues (which seem impossibly hard) let's just add name = ... # type: str to |
(Can you make a PR?) |
Also, change the type of StringIO.name (Python 3) from str to Any. Neither StringIO nor BytesIO actually define a name field, but the super-class IO[T] of both in typeshed does define a read-only property. This means that sub-classes of StringIO and BytesIO adding this field will not typecheck correctly. Closes: python#1790
Also, change the type of StringIO.name (Python 3) from str to Any. Neither StringIO nor BytesIO actually define a name field, but the super-class IO[T] of both in typeshed does define a read-only property. This means that sub-classes of StringIO and BytesIO adding this field will not typecheck correctly. Closes: #1790
Please consider the following Python 3.6 code:
mypy 0.560 complains:
This is due to the fact that in typeshed
BytesIO
derives fromBinaryIO
, which defines thename
property. The actualBytesIO
implementation does not have such an attribute:Interestingly,
StringIO
does not have this problem:This checks fine with mypy, since the
StringIO
stub includes aname
field, which also does not match the implementation:The text was updated successfully, but these errors were encountered: