-
-
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
fix: _Color
type alias of PIL.Image
#8210
Conversation
When executing `Image.new("RGB", (100,100), 255.0)`: `TypeError: color must be int or tuple` Colors will also throw an error if they are not 1-, 3-, or 4- tuples, and strings are interpolated as colors
This comment has been minimized.
This comment has been minimized.
You've hit a known mypy bug with PEP 604 type aliases: python/mypy#11098 The solution is to use an old-style |
This comment has been minimized.
This comment has been minimized.
I only noticed the mistake and corrected it while using Lines 155 and 178 are suspicious, but you have to make sure their type actually is wrong. |
Yeah, let's fix one problem at a time. |
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.
Thanks, but this isn't quite correct at the moment: see my comment below.
Co-authored-by: Alex Waygood <[email protected]>
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.
add tuple[float] to _Color
This comment has been minimized.
This comment has been minimized.
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.
Thanks!
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
The
_Color
type for Pillow'sImage
is defined as an integer, not a float.Colors will also throw an error if they are not 1-, 3-, or 4- tuples, and strings can be interpolated as colors.
Also, I think #8090 may have missed references to
_Box
on lines 155 and 178, though I could be wrong. Would that be better as its own PR?