Remove deprecated code from _fontconfig_patterns by jsjeelshah · Pull Request #26884 · matplotlib/matplotlib · GitHub
Skip to content
Merged
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
5 changes: 5 additions & 0 deletions doc/api/next_api_changes/removals/26884-JS.rst
13 changes: 2 additions & 11 deletions lib/matplotlib/_fontconfig_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import re

from pyparsing import (
Group, Optional, ParseException, Regex, StringEnd, Suppress, ZeroOrMore)

from matplotlib import _api
Optional, ParseException, Regex, StringEnd, Suppress, ZeroOrMore, oneOf)


_family_punc = r'\\\-:,'
Expand Down Expand Up @@ -63,8 +61,7 @@ def comma_separated(elem):
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"))
Expand Down Expand Up @@ -97,12 +94,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
Comment on lines -101 to -105

Copy link
Copy Markdown
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.

prop = _CONSTANTS[prop[0]]
k, *v = prop
props.setdefault(k, []).extend(map(_value_unescape, v))
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_fontconfig_pattern.py