Skip to content

Commit 2e248f5

Browse files
authored
Merge pull request #19570 from anntzer/cil
Dedupe part of error message in check_in_list.
2 parents 2db6a04 + 4eac631 commit 2e248f5

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/matplotlib/_api/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,10 @@ def check_in_list(_values, *, _print_supported_values=True, **kwargs):
122122
values = _values
123123
for key, val in kwargs.items():
124124
if val not in values:
125+
msg = f"{val!r} is not a valid value for {key}"
125126
if _print_supported_values:
126-
raise ValueError(
127-
f"{val!r} is not a valid value for {key}; "
128-
f"supported values are {', '.join(map(repr, values))}")
129-
else:
130-
raise ValueError(f"{val!r} is not a valid value for {key}")
127+
msg += f"; supported values are {', '.join(map(repr, values))}"
128+
raise ValueError(msg)
131129

132130

133131
def check_shape(_shape, **kwargs):

0 commit comments

Comments
 (0)