From 5c8c9b5c57de4ca0b96669bb005a59e7d1ad6b12 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Tue, 28 Jan 2025 00:26:43 +0100 Subject: [PATCH] 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 #29481. --- doc/api/next_api_changes/deprecations/ 29529-TH.rst | 7 +++++++ lib/matplotlib/rcsetup.py | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 doc/api/next_api_changes/deprecations/ 29529-TH.rst diff --git a/doc/api/next_api_changes/deprecations/ 29529-TH.rst b/doc/api/next_api_changes/deprecations/ 29529-TH.rst new file mode 100644 index 000000000000..e396e68c4aa1 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/ 29529-TH.rst @@ -0,0 +1,7 @@ +Capitalization of None in matplotlibrc +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In :file:`matplotlibrc` config files every capitalization of None was +accepted for denoting the Python constant `None`. This is deprecated. The +only accepted capitalization is now None, i.e. starting with a capital letter +and all other letters in lowercase. diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 04beb8126b74..e35517b07d19 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -191,6 +191,14 @@ def _make_type_validator(cls, *, allow_none=False): def validator(s): if (allow_none and (s is None or cbook._str_lower_equal(s, "none"))): + if cbook._str_lower_equal(s, "none") and s != "None": + _api.warn_deprecated( + "3.11", + message=f"Using the capitalization {s!r} in matplotlibrc for " + "*None* is deprecated in %(removal)s and will lead to an " + "error from version 3.13 onward. Please use 'None' " + "instead." + ) return None if cls is str and not isinstance(s, str): raise ValueError(f'Could not convert {s!r} to str')