From 9d04f0144ec4737400d514a389cb1eece7b70eb1 Mon Sep 17 00:00:00 2001 From: bawejahritik Date: Wed, 27 Dec 2023 07:21:53 -0500 Subject: [PATCH 1/8] Remove 3.7-deprecated APi --- lib/matplotlib/_fontconfig_pattern.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/matplotlib/_fontconfig_pattern.py b/lib/matplotlib/_fontconfig_pattern.py index d3933b9f396d..2a2eecc8038c 100644 --- a/lib/matplotlib/_fontconfig_pattern.py +++ b/lib/matplotlib/_fontconfig_pattern.py @@ -98,11 +98,7 @@ def parse_fontconfig_pattern(pattern): for prop in parse.get("properties", []): if len(prop) == 1: if prop[0] not in _CONSTANTS: - _api.warn_deprecated( - "3.7", message=f"Support for unknown constants " - f"({prop[0]!r}) is deprecated since %(since)s and " - f"will be removed %(removal)s.") - continue + raise ValueError("Support for unknown constants is not supported.") prop = _CONSTANTS[prop[0]] k, *v = prop props.setdefault(k, []).extend(map(_value_unescape, v)) From c7cb1ac8ab7acde840efc491a31fd0ef5b57e7ef Mon Sep 17 00:00:00 2001 From: bawejahritik Date: Wed, 27 Dec 2023 07:41:03 -0500 Subject: [PATCH 2/8] Remove 3.7-deprecated APi --- lib/matplotlib/_fontconfig_pattern.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/matplotlib/_fontconfig_pattern.py b/lib/matplotlib/_fontconfig_pattern.py index 2a2eecc8038c..e993be568ea3 100644 --- a/lib/matplotlib/_fontconfig_pattern.py +++ b/lib/matplotlib/_fontconfig_pattern.py @@ -15,8 +15,6 @@ from pyparsing import ( Group, Optional, ParseException, Regex, StringEnd, Suppress, ZeroOrMore) -from matplotlib import _api - _family_punc = r'\\\-:,' _family_unescape = partial(re.compile(r'\\(?=[%s])' % _family_punc).sub, '') From 98bcb6c81b57fa9e96c65801fafec2dc8c306729 Mon Sep 17 00:00:00 2001 From: bawejahritik Date: Wed, 27 Dec 2023 08:05:34 -0500 Subject: [PATCH 3/8] Remove 3.7-deprecated APi --- lib/matplotlib/tests/test_fontconfig_pattern.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/matplotlib/tests/test_fontconfig_pattern.py b/lib/matplotlib/tests/test_fontconfig_pattern.py index 792a8ed517c2..5086fa65bc68 100644 --- a/lib/matplotlib/tests/test_fontconfig_pattern.py +++ b/lib/matplotlib/tests/test_fontconfig_pattern.py @@ -71,7 +71,3 @@ def test_fontconfig_str(): for k in keys: assert getattr(font, k)() == getattr(right, k)(), test + k - -def test_fontconfig_unknown_constant(): - with pytest.warns(DeprecationWarning): - FontProperties(":unknown") From 3005a35fd15b86dad86433c65b59775db84ac538 Mon Sep 17 00:00:00 2001 From: bawejahritik Date: Wed, 27 Dec 2023 08:10:59 -0500 Subject: [PATCH 4/8] Remove 3.7-deprecated APi --- lib/matplotlib/tests/test_fontconfig_pattern.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/matplotlib/tests/test_fontconfig_pattern.py b/lib/matplotlib/tests/test_fontconfig_pattern.py index 5086fa65bc68..45c22e6fb90a 100644 --- a/lib/matplotlib/tests/test_fontconfig_pattern.py +++ b/lib/matplotlib/tests/test_fontconfig_pattern.py @@ -1,4 +1,3 @@ -import pytest from matplotlib.font_manager import FontProperties @@ -70,4 +69,3 @@ def test_fontconfig_str(): stretch="expanded") for k in keys: assert getattr(font, k)() == getattr(right, k)(), test + k - From 1c2edb2d1c96a7504c85e273fab4b924778c2a57 Mon Sep 17 00:00:00 2001 From: bawejahritik Date: Thu, 28 Dec 2023 15:59:30 -0500 Subject: [PATCH 5/8] add test_fontconfig_unknown_constant --- lib/matplotlib/tests/test_fontconfig_pattern.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/matplotlib/tests/test_fontconfig_pattern.py b/lib/matplotlib/tests/test_fontconfig_pattern.py index 45c22e6fb90a..85ab4dfad049 100644 --- a/lib/matplotlib/tests/test_fontconfig_pattern.py +++ b/lib/matplotlib/tests/test_fontconfig_pattern.py @@ -1,6 +1,7 @@ from matplotlib.font_manager import FontProperties +import pytest # Attributes on FontProperties object to check for consistency keys = [ @@ -69,3 +70,7 @@ def test_fontconfig_str(): stretch="expanded") for k in keys: assert getattr(font, k)() == getattr(right, k)(), test + k + +def test_fontconfig_unknown_constant(): + with pytest.raises(ValueError, match="Support for unknown constants is not supported."): + FontProperties(":unknown") \ No newline at end of file From 863ada7b45bce1df9ed94f9b65467fe2538b6e84 Mon Sep 17 00:00:00 2001 From: bawejahritik Date: Thu, 28 Dec 2023 16:03:02 -0500 Subject: [PATCH 6/8] add test_fontconfig_unknown_constant --- lib/matplotlib/tests/test_fontconfig_pattern.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_fontconfig_pattern.py b/lib/matplotlib/tests/test_fontconfig_pattern.py index 85ab4dfad049..e948dcd6cc70 100644 --- a/lib/matplotlib/tests/test_fontconfig_pattern.py +++ b/lib/matplotlib/tests/test_fontconfig_pattern.py @@ -72,5 +72,5 @@ def test_fontconfig_str(): assert getattr(font, k)() == getattr(right, k)(), test + k def test_fontconfig_unknown_constant(): - with pytest.raises(ValueError, match="Support for unknown constants is not supported."): - FontProperties(":unknown") \ No newline at end of file + with pytest.raises(ValueError): + FontProperties(":unknown") From 585c0badb678fb1bbe50dd19bad231d5bc53ce07 Mon Sep 17 00:00:00 2001 From: bawejahritik Date: Thu, 28 Dec 2023 16:04:15 -0500 Subject: [PATCH 7/8] add test_fontconfig_unknown_constant --- lib/matplotlib/tests/test_fontconfig_pattern.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/matplotlib/tests/test_fontconfig_pattern.py b/lib/matplotlib/tests/test_fontconfig_pattern.py index e948dcd6cc70..2e11a182edba 100644 --- a/lib/matplotlib/tests/test_fontconfig_pattern.py +++ b/lib/matplotlib/tests/test_fontconfig_pattern.py @@ -71,6 +71,7 @@ def test_fontconfig_str(): for k in keys: assert getattr(font, k)() == getattr(right, k)(), test + k + def test_fontconfig_unknown_constant(): with pytest.raises(ValueError): FontProperties(":unknown") From 9c829c4a5abc5226dde297fde1491f04074496d6 Mon Sep 17 00:00:00 2001 From: bawejahritik <53797247+bawejahritik@users.noreply.github.com> Date: Fri, 29 Dec 2023 19:25:45 -0500 Subject: [PATCH 8/8] Update lib/matplotlib/_fontconfig_pattern.py Co-authored-by: Ruth Comer <10599679+rcomer@users.noreply.github.com> --- lib/matplotlib/_fontconfig_pattern.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/_fontconfig_pattern.py b/lib/matplotlib/_fontconfig_pattern.py index e993be568ea3..5d23a65b56ad 100644 --- a/lib/matplotlib/_fontconfig_pattern.py +++ b/lib/matplotlib/_fontconfig_pattern.py @@ -96,7 +96,7 @@ def parse_fontconfig_pattern(pattern): for prop in parse.get("properties", []): if len(prop) == 1: if prop[0] not in _CONSTANTS: - raise ValueError("Support for unknown constants is not supported.") + raise ValueError(f"Unknown constants ({prop[0]!r}) are not supported.") prop = _CONSTANTS[prop[0]] k, *v = prop props.setdefault(k, []).extend(map(_value_unescape, v))