Skip to content

Commit 713f3de

Browse files
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
1 parent d11d893 commit 713f3de

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/galaxy/dependencies/pinned-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ h5py==3.11.0 ; python_version >= "3.8" and python_version < "3.9"
8686
h5py==3.12.1 ; python_version >= "3.9" and python_version < "3.13"
8787
humanfriendly==10.0 ; python_version >= "3.8" and python_version < "3.13"
8888
idna==3.10 ; python_version >= "3.8" and python_version < "3.13"
89+
puremagic=1.28 ; python_version >= "3.8" and python_version < "3.13"
8990
importlib-metadata==8.5.0 ; python_version >= "3.8" and python_version < "3.13"
9091
importlib-resources==6.4.5 ; python_version >= "3.8" and python_version < "3.9"
9192
isa-rwval @ git+https://github.com/nsoranzo/isa-rwval.git@3d989181058d2765a93cb0e7ca85d6955e0eb6ef ; python_version >= "3.8" and python_version < "3.13"

lib/galaxy/util/image_util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
Optional,
88
)
99

10+
import puremagic
11+
1012
try:
1113
from PIL import Image
1214
except ImportError:
@@ -26,7 +28,7 @@ def image_type(filename: str) -> Optional[str]:
2628
# exception we expect to happen frequently, so we're not logging
2729
pass
2830
if not fmt:
29-
fmt = imghdr.what(filename)
31+
fmt = puremagic.what(filename)
3032
if fmt:
3133
return fmt.upper()
3234
else:

0 commit comments

Comments
 (0)