8000 Ensure ImportError's have a message · matplotlib/matplotlib@b88a683 · GitHub
[go: up one dir, main page]

Skip to content

Commit b88a683

Browse files
committed
Ensure ImportError's have a message
Otherwise, you can get, e.g., a test skip with an empty message like: ``` lib/matplotlib/tests/test_getattr.py::test_getattr[matplotlib.backends.backend_gtk3] SKIPPED (Cannot import matplotlib.backends.backend_gtk3 due to) ```
1 parent 8ca75e4 commit b88a683

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

lib/matplotlib/backends/backend_cairo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
try:
1616
import cairo
1717
if cairo.version_info < (1, 14, 0): # Introduced set_device_scale.
18-
raise ImportError
18+
raise ImportError(f"Cairo backend requires cairo>=1.14.0, "
19+
f"but only {cairo.version_info} is available")
1920
except ImportError:
2021
try:
2122
import cairocffi as cairo

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
except ValueError as e:
2222
# in this case we want to re-raise as ImportError so the
2323
# auto-backend selection logic correctly skips.
24-
raise ImportError from e
24+
raise ImportError(e) from e
2525

2626
from gi.repository import Gio, GLib, GObject, Gtk, Gdk
2727
from . import _backend_gtk

lib/matplotlib/backends/backend_gtk4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
except ValueError as e:
2121
# in this case we want to re-raise as ImportError so the
2222
# auto-backend selection logic correctly skips.
23-
raise ImportError from e
23+
raise ImportError(e) from e
2424

2525
from gi.repository import Gio, GLib, Gtk, Gdk, GdkPixbuf
2626
from . import _backend_gtk

0 commit comments

Comments
 (0)
0