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

Skip to content

Remove 3.7-deprecated fontconfig api #27574

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

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions lib/matplotlib/_fontconfig_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, '')
Expand Down Expand Up @@ -98,11 +96,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(f"Unknown constants ({prop[0]!r}) are not supported.")
prop = _CONSTANTS[prop[0]]
k, *v = prop
props.setdefault(k, []).extend(map(_value_unescape, v))
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_fontconfig_pattern.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since pytest is a third party library, it was above the matplotlib import following the PEP8 style guide so ideally it should stay there.


from matplotlib.font_manager import FontProperties

import pytest

# Attributes on FontProperties object to check for consistency
keys = [
Expand Down Expand Up @@ -73,5 +73,5 @@ def test_fontconfig_str():


def test_fontconfig_unknown_constant():
with pytest.warns(DeprecationWarning):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of deleting this test, could you change the warning check to an error check? That way we can make sure the error is raised as expected.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure, I'll do that!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the test, please check

with pytest.raises(ValueError):
FontProperties(":unknown")