-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Remove deprecated code from _fontconfig_patterns #26884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
_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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should raise an error now.
The |
Hello, would I be able to work on this issue? |
Hi @0taj - this is an open pull request, meaning that another contributor is already working on it. Feel free to look at the other open issues on the repo, in particular those marked good first issue. Cheers! |
In the interest of completing this PR, I've done the rebase and pushed it here. |
Also pushed a fix to my comment at #26884 (comment) |
Actually the patch should be diff --git a/lib/matplotlib/_fontconfig_pattern.py b/lib/matplotlib/_fontconfig_pattern.py
index d3933b9f39..6e3c55d2b2 100644
--- a/lib/matplotlib/_fontconfig_pattern.py
+++ b/lib/matplotlib/_fontconfig_pattern.py
@@ -13,7 +13,7 @@ from functools import lru_cache, partial
import re
from pyparsing import (
- Group, Optional, ParseException, Regex, StringEnd, Suppress, ZeroOrMore)
+ oneOf, Optional, ParseException, Regex, StringEnd, Suppress, ZeroOrMore)
from matplotlib import _api
@@ -63,8 +63,7 @@ def _make_fontconfig_parser():
size = Regex(r"([0-9]+\.?[0-9]*|\.[0-9]+)")
name = Regex(r"[a-z]+")
value = Regex(fr"([^{_value_punc}]|(\\[{_value_punc}]))*")
- # replace trailing `| name` by oneOf(_CONSTANTS) in mpl 3.9.
- prop = Group((name + Suppress("=") + comma_separated(value)) | name)
+ prop = (name + Suppress("=") + comma_separated(value)) | oneOf(_CONSTANTS)
return (
Optional(comma_separated(family)("families"))
+ Optional("-" + comma_separated(size)("sizes"))
@@ -97,12 +96,6 @@ def parse_fontconfig_pattern(pattern):
props["size"] = [*parse["sizes"]]
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
prop = _CONSTANTS[prop[0]]
k, *v = prop
props.setdefault(k, []).extend(map(_value_unescape, v))
diff --git a/lib/matplotlib/tests/test_fontconfig_pattern.py b/lib/matplotlib/tests/test_fontconfig_pattern.py
index 792a8ed517..496a35b95c 100644
--- a/lib/matplotlib/tests/test_fontconfig_pattern.py
+++ b/lib/matplotlib/tests/test_fontconfig_pattern.py
@@ -73,5 +73,5 @@ def test_fontconfig_str():
def test_fontconfig_unknown_constant():
- with pytest.warns(DeprecationWarning):
+ with pytest.raises(ValueError, match="ParseException"):
FontProperties(":unknown") (in particular switching to oneOf makes it unnecessary to have a checked-getitem). |
Ah, good point. |
I've rebased and corrected the API note. |
@jsjeelshah Thank you and congrats on your first merged PR! Hope to hear from you again! |
PR summary
This PR removes the deprecated code during the version 3.7 from lib/matplotlib/gridspec.py and lib/matplotlib/_fontconfig_patterns.py issues here: #26865.
PR checklist