Skip to content

Commit d186a2a

Browse files
committed
Replace NotImplementedError with abstractmethod
1 parent 2309f0f commit d186a2a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/PIL/ImageFile.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -447,17 +447,17 @@ def load(self, im: StubImageFile) -> Image.Image:
447447
pass
448448

449449

450-
class StubImageFile(ImageFile):
450+
class StubImageFile(ImageFile, metaclass=abc.ABCMeta):
451451
"""
452452
Base class for stub image loaders.
453453
454454
A stub loader is an image loader that can identify files of a
455455
certain format, but relies on external code to load the file.
456456
"""
457457

458+
@abc.abstractmethod
458459
def _open(self) -> None:
459-
msg = "StubImageFile subclass must implement _open"
460-
raise NotImplementedError(msg)
460+
pass
461461

462462
def load(self) -> Image.core.PixelAccess | None:
463463
loader = self._load()
@@ -471,10 +471,10 @@ def load(self) -> Image.core.PixelAccess | None:
471471
self.__dict__ = image.__dict__
472472
return image.load()
473473

474+
@abc.abstractmethod
474475
def _load(self) -> StubHandler | None:
475476
"""(Hook) Find actual image loader."""
476-
msg = "StubImageFile subclass must implement _load"
477-
raise NotImplementedError(msg)
477+
pass
478478

479479

480480
class Parser:

0 commit comments

Comments
 (0)