Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 14a30f6

Browse files
committed
Improve error for quoted values in matplotlibrc.
... as the need for unquoted values in the matplotlibrc is slightly confusing. Also reword the error message to match the one in _check_in_list/_check_getitem.
1 parent f2b6c66 commit 14a30f6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/matplotlib/rcsetup.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,13 @@ def __call__(self, s):
7272
s = s.lower()
7373
if s in self.valid:
7474
return self.valid[s]
75-
raise ValueError('Unrecognized %s string %r: valid strings are %s'
76-
% (self.key, s, list(self.valid.values())))
75+
msg = (f"{s!r} is not a valid value for {self.key}; supported values "
76+
f"are {[*self.valid.values()]}")
77+
if ((s.startswith('"') and s.endswith('"')
78+
or s.startswith("'") and s.endswith("'"))
79+
and s[1:-1] in self.valid):
80+
msg += f"; remove quotes surrounding your string"
81+
raise ValueError(msg)
7782

7883

7984
def _listify_validator(scalar_validator, allow_stringlist=False, *, doc=None):

0 commit comments

Comments
 (0)