Add type hints for `Image.open`, `Image.init`, and `Image.Image.save` by nulano · Pull Request #7944 · python-pillow/Pillow
Fixes #7941
While the Image.open function is currently marked as returning an Image object, it does so by calling a factory function from OPEN, which is marked as returning an ImageFile:
Lines 222 to 228 in e8ab564
| OPEN: dict[ | |
| str, | |
| tuple[ | |
| Callable[[IO[bytes], str | bytes], ImageFile.ImageFile], | |
| Callable[[bytes], bool] | None, | |
| ], | |
| ] = {} |
The accept function usually returns a bool, but I found one case (webp) where it can return a str instead to be used as a warning.