Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

jsjeelshah
Copy link
Contributor

@jsjeelshah jsjeelshah commented Sep 22, 2023

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

Copy link

@github-actions github-actions bot left a 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.

@jsjeelshah jsjeelshah marked this pull request as ready for review September 22, 2023 23:26
@QuLogic QuLogic added this to the v3.9.0 milestone Sep 23, 2023
Comment on lines -101 to -105
_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
Copy link
Member

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.

@QuLogic
Copy link
Member

QuLogic commented Sep 26, 2023

The gridspec part was done in #26885; can you please rebase this and focus only on the _fontconfig_patterns part?

@0taj
Copy link
Contributor

0taj commented Oct 17, 2023

Hello, would I be able to work on this issue?

@melissawm
Copy link
Member

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!

@QuLogic
Copy link
Member

QuLogic commented Dec 6, 2023

In the interest of completing this PR, I've done the rebase and pushed it here.

@QuLogic QuLogic changed the title removed deprecated code from gridspec.py and _fontconfig_patterns.py Remove deprecated code from _fontconfig_patterns Dec 6, 2023
@QuLogic
Copy link
Member

QuLogic commented Dec 6, 2023

Also pushed a fix to my comment at #26884 (comment)

@anntzer
Copy link
Contributor

anntzer commented Dec 7, 2023

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).

@QuLogic
Copy link
Member

QuLogic commented Dec 8, 2023

Ah, good point.

@QuLogic
Copy link
Member

QuLogic commented Jan 3, 2024

I've rebased and corrected the API note.

@ksunden ksunden merged commit 843f585 into matplotlib:main Jan 8, 2024
@ksunden
Copy link
Member

ksunden commented Jan 8, 2024

@jsjeelshah Thank you and congrats on your first merged PR! Hope to hear from you again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

6 participants