mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 01:04:29 +03:00
Require fp parameter
This commit is contained in:
parent
d00f3656a6
commit
8699f13a74
|
@ -34,7 +34,7 @@ import itertools
|
|||
import os
|
||||
import struct
|
||||
import sys
|
||||
from typing import IO, TYPE_CHECKING, Any, NamedTuple
|
||||
from typing import IO, TYPE_CHECKING, Any, NamedTuple, cast
|
||||
|
||||
from . import Image
|
||||
from ._deprecate import deprecate
|
||||
|
@ -111,7 +111,7 @@ class ImageFile(Image.Image):
|
|||
"""Base class for image file format handlers."""
|
||||
|
||||
def __init__(
|
||||
self, fp: StrOrBytesPath | IO[bytes] | None = None, filename: str | bytes | None = None
|
||||
self, fp: StrOrBytesPath | IO[bytes], filename: str | bytes | None = None
|
||||
) -> None:
|
||||
super().__init__()
|
||||
|
||||
|
@ -134,7 +134,7 @@ class ImageFile(Image.Image):
|
|||
self._exclusive_fp = True
|
||||
else:
|
||||
# stream
|
||||
self.fp = fp
|
||||
self.fp = cast(IO[bytes], fp)
|
||||
self.filename = filename if filename is not None else ""
|
||||
# can be overridden
|
||||
self._exclusive_fp = False
|
||||
|
|
|
@ -848,7 +848,7 @@ def _save_cjpeg(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
|||
##
|
||||
# Factory for making JPEG and MPO instances
|
||||
def jpeg_factory(
|
||||
fp: IO[bytes] | None = None, filename: str | bytes | None = None
|
||||
fp: IO[bytes], filename: str | bytes | None = None
|
||||
) -> JpegImageFile | MpoImageFile:
|
||||
im = JpegImageFile(fp, filename)
|
||||
try:
|
||||
|
|
|
@ -1126,7 +1126,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
fp: StrOrBytesPath | IO[bytes] | None = None,
|
||||
fp: StrOrBytesPath | IO[bytes],
|
||||
filename: str | bytes | None = None,
|
||||
) -> None:
|
||||
self.tag_v2: ImageFileDirectory_v2
|
||||
|
|
Loading…
Reference in New Issue
Block a user