Skip to content

Commit 9b436f3

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 9b436f3

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
@@ -133,6 +133,7 @@ propcache==0.2.0 ; python_version >= "3.8" and python_version < "3.13"
133133
prov==1.5.1 ; python_version >= "3.8" and python_version < "3.13"
134134
psutil==6.1.0 ; python_version >= "3.8" and python_version < "3.13"
135135
pulsar-galaxy-lib==0.15.6 ; python_version >= "3.8" and python_version < "3.13"
136+
puremagic==1.28 ; python_version >= "3.8" and python_version < "3.13"
136137
pycparser==2.22 ; python_version >= "3.8" and python_version < "3.13"
137138
pycryptodome==3.21.0 ; python_version >= "3.8" and python_version < "3.13"
138139
pydantic-core==2.23.4 ; 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)