Skip to content

Commit 5c8c9b5

Browse files
committed
MNT: Deprecate other capitalization than "None" in matplotlibrc
The `*_or_None` validators have accepted any capitalization of the string "none" as input. This is overly permissive and will likely lead to conflicts in the future because we cannot distinguish between resolving to `None` and `"none"` which may be need for some parameters in the future. Inspired by matplotlib#29481.
1 parent 9e3ada3 commit 5c8c9b5

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Capitalization of None in matplotlibrc
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
In :file:`matplotlibrc` config files every capitalization of None was
5+
accepted for denoting the Python constant `None`. This is deprecated. The
6+
only accepted capitalization is now None, i.e. starting with a capital letter
7+
and all other letters in lowercase.

lib/matplotlib/rcsetup.py

+8
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ def _make_type_validator(cls, *, allow_none=False):
191191
def validator(s):
192192
if (allow_none and
193193
(s is None or cbook._str_lower_equal(s, "none"))):
194+
if cbook._str_lower_equal(s, "none") and s != "None":
195+
_api.warn_deprecated(
196+
"3.11",
197+
message=f"Using the capitalization {s!r} in matplotlibrc for "
198+
"*None* is deprecated in %(removal)s and will lead to an "
199+
"error from version 3.13 onward. Please use 'None' "
200+
"instead."
201+
)
194202
return None
195203
if cls is str and not isinstance(s, str):
196204
raise ValueError(f'Could not convert {s!r} to str')

0 commit comments

Comments
 (0)