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

Skip to content

Commit 04e950a

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 04e950a

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

lib/matplotlib/rcsetup.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,14 @@ 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 (isinstance(s, str)
78+
and (s.startswith('"') and s.endswith('"')
79+
or s.startswith("'") and s.endswith("'"))
80+
and s[1:-1] in self.valid):
81+
msg += "; remove quotes surrounding your string"
82+
raise ValueError(msg)
7783

7884

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

0 commit comments

Comments
 (0)