Skip to content

Commit 1aab9ad

Browse files
committed
Use f-strings and more explicit variable names
1 parent 8b675a7 commit 1aab9ad

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2249,31 +2249,31 @@ def _check_in_list(_values, *, _print_supported_values=True, **kwargs):
22492249
Parameters
22502250
----------
22512251
_values : iterable
2252-
Sequence of values to check on
2252+
Sequence of values to check on.
22532253
_print_supported_values : bool, default: True
2254-
Whether to print *_values* when raising ValueError
2255-
**kwargs : dict-like
2256-
*key, value* pairs as keyword arguments to find in *_values*
2254+
Whether to print *_values* when raising ValueError.
2255+
**kwargs : dict
2256+
*key, value* pairs as keyword arguments to find in *_values*.
22572257
22582258
Raises
22592259
------
22602260
ValueError
2261-
If any *value* in *kwargs* is not found in *_values*
2261+
If any *value* in *kwargs* is not found in *_values*.
22622262
22632263
Examples
22642264
--------
22652265
>>> cbook._check_in_list(["foo", "bar"], arg=arg, other_arg=other_arg)
22662266
"""
22672267
values = _values
2268-
for k, v in kwargs.items():
2269-
if v not in values:
2268+
for key, val in kwargs.items():
2269+
if val not in values:
22702270
if _print_supported_values:
22712271
raise ValueError(
2272-
"{!r} is not a valid value for {}; supported values are {}"
2273-
.format(v, k, ', '.join(map(repr, values))))
2272+
f"{val!r} is not a valid value for {key}; "
2273+
f"supported values are {', '.join(map(repr, values))}")
22742274
else:
22752275
raise ValueError(
2276-
"{!r} is not a valid value for {}".format(v, k))
2276+
f"{val!r} is not a valid value for {key}")
22772277

22782278

22792279
def _check_shape(_shape, **kwargs):

0 commit comments

Comments
 (0)