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