Skip to content

fix: remove list from putpixel value type annotation#9781

Closed
muhamedfazalps wants to merge 1 commit into
python-pillow:mainfrom
muhamedfazalps:fix/putpixel-type-annotation
Closed

fix: remove list from putpixel value type annotation#9781
muhamedfazalps wants to merge 1 commit into
python-pillow:mainfrom
muhamedfazalps:fix/putpixel-type-annotation

Conversation

@muhamedfazalps

Copy link
Copy Markdown

The putpixel method's value parameter was typed as accepting list[int], but the underlying C code only accepts tuple or int, causing a TypeError at runtime when a list is passed.

Fixes #9584

The putpixel method's value parameter was typed as accepting list[int],
but the underlying C code only accepts tuple or int, causing a TypeError
at runtime when a list is passed.

Fixes python-pillow#9584
@radarhere

Copy link
Copy Markdown
Member

This is a similar to #9586, except only changing the type hint, without the deprecation.

@radarhere

radarhere commented Jul 7, 2026

Copy link
Copy Markdown
Member

I think this is incomplete. It changes the type hint, but doesn't update

and isinstance(value, (list, tuple))

so putpixel() does still support lists for P and PA modes, it just stops advertising it through the type hint.

This PR changes the method from
saying it accepts lists, but only working for P and PA modes
to
saying it doesn't accept lists, but actually still accepting them for P and PA modes. This is still incorrect, just in a different way.

My PR removes the type hint to stop advertising the functionality, deprecates the use of lists, and then a year after deprecation, the functionality can be removed for P and PA modes.

@radarhere radarhere closed this Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image.putpixel incorrectly labels supported arguments in type annotations

2 participants