Skip to content

Conversation

radarhere
Copy link
Member

@radarhere radarhere commented Jun 28, 2025

This is part of #8362 - I'm hoping to break down that PR into easier-to-review chunks.

  1. Assert getpixel() returns a tuple, before using index access, since it might also return a float or None.

    Pillow/src/PIL/Image.py

    Lines 1645 to 1647 in a370209

    def getpixel(
    self, xy: tuple[int, int] | list[int]
    ) -> float | tuple[int, ...] | None:
  2. Assert that getcolors() does not return None, before checking length or using index access.

    Pillow/src/PIL/Image.py

    Lines 1415 to 1417 in a370209

    def getcolors(
    self, maxcolors: int = 256
    ) -> list[tuple[int, tuple[int, ...]]] | list[tuple[int, float]] | None:
  3. Assert that getpalette() does not return None before slicing a list.
    def getpalette(self, rawmode: str | None = "RGB") -> list[int] | None:

@hugovk hugovk merged commit 1148b7a into python-pillow:main Oct 15, 2025
66 of 67 checks passed
@radarhere radarhere deleted the type_hint branch October 15, 2025 08:08
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.

2 participants