Skip to content

Commit

Permalink
Merge pull request python-pillow#8354 from radarhere/type_hint
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Sep 8, 2024
2 parents 89c790f + 8b3ef37 commit f30eefa
Show file tree
Hide file tree
Showing 20 changed files with 199 additions and 150 deletions.
4 changes: 3 additions & 1 deletion Tests/test_file_jpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,9 @@ def test_eof(self) -> None:
# Even though this decoder never says that it is finished
# the image should still end when there is no new data
class InfiniteMockPyDecoder(ImageFile.PyDecoder):
def decode(self, buffer: bytes) -> tuple[int, int]:
def decode(
self, buffer: bytes | Image.SupportsArrayInterface
) -> tuple[int, int]:
return 0, 0

Image.register_decoder("INFINITE", InfiniteMockPyDecoder)
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_imagefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def __init__(self, mode: str, *args: Any) -> None:

super().__init__(mode, *args)

def decode(self, buffer: bytes) -> tuple[int, int]:
def decode(self, buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int]:
# eof
return -1, 0

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
# generating warnings in “nitpicky mode”. Note that type should include the domain name
# if present. Example entries would be ('py:func', 'int') or
# ('envvar', 'LD_LIBRARY_PATH').
# nitpick_ignore = []
nitpick_ignore = [("py:class", "_io.BytesIO")]


# -- Options for HTML output ----------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions docs/example/DdsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def load_seek(self, pos: int) -> None:
class DXT1Decoder(ImageFile.PyDecoder):
_pulls_fd = True

def decode(self, buffer: bytes) -> tuple[int, int]:
def decode(self, buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int]:
assert self.fd is not None
try:
self.set_as_raw(_dxt1(self.fd, self.state.xsize, self.state.ysize))
Expand All @@ -270,7 +270,7 @@ def decode(self, buffer: bytes) -> tuple[int, int]:
class DXT5Decoder(ImageFile.PyDecoder):
_pulls_fd = True

def decode(self, buffer: bytes) -> tuple[int, int]:
def decode(self, buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int]:
assert self.fd is not None
try:
self.set_as_raw(_dxt5(self.fd, self.state.xsize, self.state.ysize))
Expand Down
4 changes: 4 additions & 0 deletions docs/reference/internal_modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ Internal Modules
Provides a convenient way to import type hints that are not available
on some Python versions.

.. py:class:: Buffer
Typing alias.

.. py:class:: IntegralLike
Typing alias.
Expand Down
Loading

0 comments on commit f30eefa

Please sign in to comment.