Skip to content

Commit 58dec4b

Browse files
committed
Let mpl.style.use error out on invalid styles
1 parent 1dcf301 commit 58dec4b

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

stagpy/__init__.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,18 @@ def load_mplstyle() -> None:
8080
import matplotlib.style as mpls
8181
if conf.plot.mplstyle:
8282
for style in conf.plot.mplstyle.split():
83-
found = False
8483
style_fname = style + ".mplstyle"
8584
if not ISOLATED:
8685
stfile = config.CONFIG_DIR / style_fname
8786
if stfile.is_file():
88-
found = True
89-
style = str(stfile)
90-
if not found:
91-
# try local version
92-
if imlr.is_resource(_styles, style_fname):
93-
with imlr.path(_styles, style_fname) as stfile:
94-
mpls.use(str(stfile))
95-
continue
96-
try:
97-
mpls.use(style)
98-
except OSError:
99-
print(f'Cannot import style {style}.', file=sys.stderr)
100-
conf.plot.mplstyle = ''
87+
mpls.use(str(stfile))
88+
continue
89+
# try packaged version
90+
if imlr.is_resource(_styles, style_fname):
91+
with imlr.path(_styles, style_fname) as stfile:
92+
mpls.use(str(stfile))
93+
continue
94+
mpls.use(style)
10195
if conf.plot.xkcd:
10296
import matplotlib.pyplot as plt
10397
plt.xkcd()

0 commit comments

Comments
 (0)