-
-
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
Return type for PIL.Image.load
#9466
Conversation
This comment has been minimized.
This comment has been minimized.
204f170
to
d577e0a
Compare
This comment has been minimized.
This comment has been minimized.
Pillow.load
PIL.Image.load
(I am not a maintainer, I just contribute a lot here)
|
If a solution is found for the return type. Do you think you could do all the other |
This comment has been minimized.
This comment has been minimized.
@DMRobertson could you respond to Avasam's feedback? |
Apologies all for the delay in responding. I have some spare time now; let me see if I can fix this up. |
Taking a look at this with fresher eyes, I think(?) the history here is:
So I think these really are meant to be implementations of the same interface. For that reason, I think returning a protocol rather than
Similarly, I think the PIL authors don't really intend for any downstream user to care about the distinction between PixelAccess and PyAccess, so I don't think what you describe is likely to be a problem in practice. (Though let's see what the primer says.)
Sure, I can add that. |
I think returning A protocol can be closer to what PIL authors intended, but typeshed generally types things with a "practicality beats purity" mindset, and IMO adding a fictional protocol wouldn't be very practical. |
Already defined on Image
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
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.
While I don't like the fictional protocol, this is a big improvement over -> None
and can be improved in future PRs.
A first step towards #9126.
Points I wasn't sure about:
PixelAccess | PyAccess
return value actually get us anything? E.g. perhaps a Protocol describing the common parts of these two would be more useful