Skip to content

Commit dbd779d

Browse files
committed
Make AbstractSlide.set_cache() non-abstract
It was added in 1.2.0, so any older third-party subclass may not implement the method. In addition, most subclasses will want this method to do nothing, matching ImageSlide's implementation. Make the default implementation do nothing and remove the method override from ImageSlide. Signed-off-by: Benjamin Gilbert <[email protected]>
1 parent d821e18 commit dbd779d

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

openslide/__init__.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,13 @@ def read_region(
161161
size: (width, height) tuple giving the region size."""
162162
raise NotImplementedError
163163

164-
@abstractmethod
165-
def set_cache(self, cache: OpenSlideCache) -> None:
164+
def set_cache(self, cache: OpenSlideCache) -> None: # noqa: B027
166165
"""Use the specified cache to store recently decoded slide tiles.
167166
167+
This class does not support caching, so this method does nothing.
168+
168169
cache: an OpenSlideCache object."""
169-
raise NotImplementedError
170+
pass
170171

171172
def get_thumbnail(self, size: tuple[int, int]) -> Image.Image:
172173
"""Return a PIL.Image containing an RGB thumbnail of the image.
@@ -486,14 +487,6 @@ def read_region(
486487
tile.info['icc_profile'] = self._profile
487488
return tile
488489

489-
def set_cache(self, cache: OpenSlideCache) -> None:
490-
"""Use the specified cache to store recently decoded slide tiles.
491-
492-
ImageSlide does not support caching, so this method does nothing.
493-
494-
cache: an OpenSlideCache object."""
495-
pass
496-
497490

498491
def open_slide(filename: lowlevel.Filename) -> OpenSlide | ImageSlide:
499492
"""Open a whole-slide or regular image.

0 commit comments

Comments
 (0)