Skip to content

Commit

Permalink
add type hints for Image.save
Browse files Browse the repository at this point in the history
  • Loading branch information
nulano committed Apr 4, 2024
1 parent 8c14a39 commit 819e1b9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,9 @@ def transform(x, y, matrix):
(w, h), Transform.AFFINE, matrix, resample, fillcolor=fillcolor
)

def save(self, fp, format=None, **params) -> None:
def save(
self, fp: StrOrBytesPath | IO[bytes], format: str | None = None, **params: Any
) -> None:
"""
Saves this image under the given filename. If no format is
specified, the format to use is determined from the filename
Expand Down Expand Up @@ -2455,6 +2457,8 @@ def save(self, fp, format=None, **params) -> None:
fp = builtins.open(filename, "r+b")
else:
fp = builtins.open(filename, "w+b")
else:
fp = cast(IO[bytes], fp)

try:
save_handler(self, fp, filename)
Expand Down

0 comments on commit 819e1b9

Please sign in to comment.