Skip to content

Conversation

radarhere
Copy link
Member

@radarhere radarhere commented Sep 10, 2024

Removes isImageType(), which relies on hasattr(t, "im"),

Pillow/src/PIL/Image.py

Lines 125 to 136 in be01d53

def isImageType(t: Any) -> TypeGuard[Image]:
"""
Checks if an object is an image object.
.. warning::
This function is for internal use only.
:param t: object to check if it's an image
:returns: True if the object is an image
"""
return hasattr(t, "im")

and instead uses isinstance(im, Image).

I've also made a similar change in ImageMath, replacing hasattr(v, "im") with isinstance(v, Image.Image).

Comment on lines 1847 to 1863
elif isinstance(im, tuple):
source = im
else:
source = cast(float, im)
source = im
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This elif could be removed now since it does the same thing as the else below it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I've updated the commit.

@radarhere radarhere added Deprecation Feature that will be removed in the future and removed Cleanup labels Sep 10, 2024
@radarhere radarhere changed the title Replaced isImageType with isinstance Deprecate isImageType Sep 10, 2024
@hugovk hugovk merged commit 4e5fd27 into python-pillow:main Sep 10, 2024
48 checks passed
@hugovk
Copy link
Member

hugovk commented Sep 10, 2024

Thank you.

@radarhere radarhere deleted the isimagetype branch September 10, 2024 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Deprecation Feature that will be removed in the future

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants