Skip to content

Commit 629d3f6

Browse files
committed
replace deprecated stdlib imghdr with filetype
1 parent e6f0b06 commit 629d3f6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

bash_kernel/display.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@
5252
is your friend to debug the format of the content message.
5353
"""
5454
import base64
55-
import imghdr
5655
import json
5756
import os
5857
import re
5958

59+
import filetype
60+
6061

6162
_TEXT_SAVED_IMAGE = "bash_kernel: saved image data to: "
6263
_TEXT_SAVED_HTML = "bash_kernel: saved html data to: "
@@ -101,8 +102,7 @@ def display_data_for_image(filename):
101102
with open(filename, 'rb') as f:
102103
image = f.read()
103104
_unlink_if_temporary(filename)
104-
105-
image_type = imghdr.what(None, image)
105+
image_type = filetype.image_match(image).extension
106106
if image_type is None:
107107
raise ValueError("Not a valid image: %s" % image)
108108

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ authors = [
88
{name = "Thomas Kluyver", email = "thomas@kluyver.me.uk"},
99
]
1010
readme = "README.rst"
11-
dependencies = ["pexpect (>=4.0)", "ipykernel"]
11+
dependencies = ["pexpect (>=4.0)", "ipykernel", "filetype"]
1212
classifiers = [
1313
"Framework :: Jupyter",
1414
"License :: OSI Approved :: BSD License",

0 commit comments

Comments
 (0)