Skip to content

Commit fe4ab50

Browse files
committed
Simplify _warn_proplot, remove action
1 parent 9dfe041 commit fe4ab50

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

proplot/config.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,19 +1597,16 @@ def _load_file(self, path):
15971597
try:
15981598
ikw_proplot, ikw_matplotlib = self._get_item_dicts(key, val)
15991599
except KeyError:
1600-
warnings._warn_proplot(
1601-
f'Invalid rc key {key!r} on {message}.', 'default'
1602-
)
1600+
warnings.simplefilter('default', warnings.ProplotWarning)
1601+
warnings._warn_proplot(f'Invalid rc key {key!r} on {message}.')
16031602
continue
16041603
except ValueError as err:
1605-
warnings._warn_proplot(
1606-
f'Invalid rc val {val!r} for key {key!r} on {message}: {err}', 'default' # noqa: E501
1607-
)
1604+
warnings.simplefilter('default', warnings.ProplotWarning)
1605+
warnings._warn_proplot(f'Invalid rc val {val!r} for key {key!r} on {message}: {err}') # noqa: E501
16081606
continue
16091607
except warnings.ProplotWarning as err:
1610-
warnings._warn_proplot(
1611-
f'Outdated rc key {key!r} on {message}: {err}', 'default'
1612-
)
1608+
warnings.simplefilter('default', warnings.ProplotWarning)
1609+
warnings._warn_proplot(f'Outdated rc key {key!r} on {message}: {err}') # noqa: E501
16131610
warnings.simplefilter('ignore', warnings.ProplotWarning)
16141611
ikw_proplot, ikw_matplotlib = self._get_item_dicts(key, val)
16151612
# Update the settings

proplot/internals/warnings.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _next_release():
3535
return string
3636

3737

38-
def _warn_proplot(message, action=None):
38+
def _warn_proplot(message):
3939
"""
4040
Emit a `ProplotWarning` and show the stack level outside of matplotlib and
4141
proplot. This is adapted from matplotlib's warning system.
@@ -47,10 +47,7 @@ def _warn_proplot(message, action=None):
4747
break # this is the first external frame
4848
frame = frame.f_back
4949
stacklevel += 1
50-
with warnings.catch_warnings():
51-
if action: # used internally
52-
warnings.simplefilter(action, ProplotWarning)
53-
warnings.warn(message, ProplotWarning, stacklevel=stacklevel)
50+
warnings.warn(message, ProplotWarning, stacklevel=stacklevel)
5451

5552

5653
def _rename_objs(version, **kwargs):

0 commit comments

Comments
 (0)