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

Skip to content

Commit bcc2852

Browse files
authored
Merge pull request #16960 from anntzer/unquoted-rc
MNT: Improve error for quoted values in matplotlibrc.
2 parents 0e4685b + 04e950a commit bcc2852

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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)