add type hints for Image.save

This commit is contained in:
Nulano 2024-04-04 23:38:50 +02:00
parent 8c14a394c1
commit 819e1b9dd2

View File

@ -2374,7 +2374,9 @@ class Image:
(w, h), Transform.AFFINE, matrix, resample, fillcolor=fillcolor (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 Saves this image under the given filename. If no format is
specified, the format to use is determined from the filename specified, the format to use is determined from the filename
@ -2455,6 +2457,8 @@ class Image:
fp = builtins.open(filename, "r+b") fp = builtins.open(filename, "r+b")
else: else:
fp = builtins.open(filename, "w+b") fp = builtins.open(filename, "w+b")
else:
fp = cast(IO[bytes], fp)
try: try:
save_handler(self, fp, filename) save_handler(self, fp, filename)