Skip to content

Commit

Permalink
Require fp parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Aug 30, 2024
1 parent d00f365 commit 8699f13
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/PIL/ImageFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
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
Expand Down Expand Up @@ -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__()

Expand All @@ -134,7 +134,7 @@ def __init__(
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
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/JpegImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8699f13

Please sign in to comment.