Skip to content

Commit

Permalink
Make validation whitelist dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
sgdecker committed Oct 25, 2021
1 parent 0922ea8 commit 91ec453
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/metpy/plots/declarative.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def plot_kwargs(data):
return kwargs


class ValidationMixin(object):
class ValidationMixin:
"""Provides validation of attribute names when set by user."""

def __setattr__(self, name, value):
Expand All @@ -530,25 +530,11 @@ def _levenshtein(s1, s2):
distances = new_distances
return distances[-1]

whitelist = ('area',
'ax',
'clabels',
'contours',
'data',
'layers',
'layout',
'linecolor',
whitelist = ['ax',
'notify_change',
'panels',
'parent',
'plot_units',
'plots',
'projection',
'size',
'title',
'title_fontsize',
)
]

whitelist.extend(self.trait_names())
if name in whitelist or name.startswith('_'):
super().__setattr__(name, value)
else:
Expand Down

0 comments on commit 91ec453

Please sign in to comment.