Simplify code and update comments

Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
This commit is contained in:
Hugo van Kemenade 2024-03-31 23:13:30 -06:00 committed by GitHub
parent 9f5d6e0c31
commit 512ee3ff9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -258,20 +258,20 @@ def hopper(mode: str | None = None) -> Image.Image:
if mode is None: if mode is None:
# Always return fresh not-yet-loaded version of image. # Always return fresh not-yet-loaded version of image.
# Operations on not-yet-loaded images is separate class of errors # Operations on not-yet-loaded images are a separate class of errors
# what we should catch. # that we should catch.
return Image.open("Tests/images/hopper.ppm") return Image.open("Tests/images/hopper.ppm")
return _cached_hopper(mode).copy() return _cached_hopper(mode).copy()
@lru_cache(maxsize=None) @lru_cache
def _cached_hopper(mode: str = None) -> Image.Image: def _cached_hopper(mode: str) -> Image.Image:
if mode == "F": if mode == "F":
im = hopper("L").convert(mode) im = hopper("L")
else: else:
im = hopper().convert(mode) im = hopper()
return im return im.convert(mode)
def djpeg_available() -> bool: def djpeg_available() -> bool: