Skip to content

Conversation

@radarhere
Copy link
Member

@radarhere radarhere commented Dec 26, 2023

Helps #2625.

Resolves #6676. Also suggested in #7635 (review)

When using the Image class as a type hint, you must currently use from PIL import Image; Image.Image.

This PR allows for from PIL import ImageType; ImageType.

hugovk
hugovk previously approved these changes Dec 26, 2023
@nulano
Copy link
Contributor

nulano commented Dec 26, 2023

I wasn't sure how this would affect the docs, but it looks good:

image

Should ImageType be documented somewhere? Not sure how it would be done, since I couldn't find a type alias directive in sphinx: https://www.sphinx-doc.org/en/master/usage/domains/python.html

@radarhere
Copy link
Member Author

Ok, I've added it to the docs - https://pillow--7639.org.readthedocs.build/en/7639/reference/Image.html

Screenshot 2023-12-27 at 10 03 33 am

@hugovk hugovk dismissed their stale review December 29, 2023 19:42

See below.

@hugovk
Copy link
Member

hugovk commented Dec 29, 2023

I know I suggested this in the first place, but after some thought, perhaps it's not so useful after all.

Image.Image vs ImageType is adding abstraction on top of something which isn't particularly complex in the first place, only save two chars, at the cost of another layer of indirection.

I can see aliases may be more useful for more complex things, such as tuples of ints for RGB etc, but I think we should pass on this one.

@radarhere radarhere closed this Dec 29, 2023
@radarhere radarhere deleted the imagetype branch December 29, 2023 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Typing difficulty because Image is a module and also a class

3 participants