From 9b3a7d7d08aee1fff8c87f64780c92512d392984 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Tue, 29 Oct 2024 12:38:10 +0100 Subject: [PATCH] replace imghdr by puremagic imghdr allowed to detect a few imagetimes and has been deprecated in python 3.13: https://docs.python.org/3.12/library/imghdr.html from the release notes: > The filetype, puremagic, or python-magic libraries should be used as replacements. > For example, the puremagic.what() function can be used to replace the imghdr.what() > function for all file formats that were supported by imghdr. See also https://github.com/cdgriffith/puremagic/blob/763349ec4d02ba930fb1142c6eb684afdf06c6ab/puremagic/main.py#L421 --- lib/galaxy/dependencies/pinned-requirements.txt | 1 + lib/galaxy/util/image_util.py | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/galaxy/dependencies/pinned-requirements.txt b/lib/galaxy/dependencies/pinned-requirements.txt index 91752afea326..306980686438 100644 --- a/lib/galaxy/dependencies/pinned-requirements.txt +++ b/lib/galaxy/dependencies/pinned-requirements.txt @@ -86,6 +86,7 @@ h5py==3.11.0 ; python_version >= "3.8" and python_version < "3.9" h5py==3.12.1 ; python_version >= "3.9" and python_version < "3.13" humanfriendly==10.0 ; python_version >= "3.8" and python_version < "3.13" idna==3.10 ; python_version >= "3.8" and python_version < "3.13" +puremagic=1.28 ; python_version >= "3.8" and python_version < "3.13" importlib-metadata==8.5.0 ; python_version >= "3.8" and python_version < "3.13" importlib-resources==6.4.5 ; python_version >= "3.8" and python_version < "3.9" isa-rwval @ git+https://github.com/nsoranzo/isa-rwval.git@3d989181058d2765a93cb0e7ca85d6955e0eb6ef ; python_version >= "3.8" and python_version < "3.13" diff --git a/lib/galaxy/util/image_util.py b/lib/galaxy/util/image_util.py index 3b11a50d2fda..146807fcb2aa 100644 --- a/lib/galaxy/util/image_util.py +++ b/lib/galaxy/util/image_util.py @@ -25,8 +25,6 @@ def image_type(filename: str) -> Optional[str]: # We continue to try with imghdr, so this is a rare case of an # exception we expect to happen frequently, so we're not logging pass - if not fmt: - fmt = imghdr.what(filename) if fmt: return fmt.upper() else: