Skip to content

Commit 6ee8884

Browse files
committed
Upgrade pyparsing to 3.1.0
1 parent 856c7ec commit 6ee8884

File tree

13 files changed

+1232
-769
lines changed

13 files changed

+1232
-769
lines changed

news/pyparsing.vendor.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgrade pyparsing to 3.1.0

src/pip/_vendor/pyparsing/__init__.py

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
:class:`'|'<MatchFirst>`, :class:`'^'<Or>` and :class:`'&'<Each>` operators.
5757
5858
The :class:`ParseResults` object returned from
59-
:class:`ParserElement.parseString` can be
59+
:class:`ParserElement.parse_string` can be
6060
accessed as a nested list, a dictionary, or an object with named
6161
attributes.
6262
@@ -85,11 +85,11 @@
8585
and :class:`'&'<Each>` operators to combine simple expressions into
8686
more complex ones
8787
- associate names with your parsed results using
88-
:class:`ParserElement.setResultsName`
88+
:class:`ParserElement.set_results_name`
8989
- access the parsed data, which is returned as a :class:`ParseResults`
9090
object
91-
- find some helpful expression short-cuts like :class:`delimitedList`
92-
and :class:`oneOf`
91+
- find some helpful expression short-cuts like :class:`DelimitedList`
92+
and :class:`one_of`
9393
- find more useful common expressions in the :class:`pyparsing_common`
9494
namespace class
9595
"""
@@ -106,30 +106,22 @@ class version_info(NamedTuple):
106106
@property
107107
def __version__(self):
108108
return (
109-
"{}.{}.{}".format(self.major, self.minor, self.micro)
109+
f"{self.major}.{self.minor}.{self.micro}"
110110
+ (
111-
"{}{}{}".format(
112-
"r" if self.releaselevel[0] == "c" else "",
113-
self.releaselevel[0],
114-
self.serial,
115-
),
111+
f"{'r' if self.releaselevel[0] == 'c' else ''}{self.releaselevel[0]}{self.serial}",
116112
"",
117113
)[self.releaselevel == "final"]
118114
)
119115

120116
def __str__(self):
121-
return "{} {} / {}".format(__name__, self.__version__, __version_time__)
117+
return f"{__name__} {self.__version__} / {__version_time__}"
122118

123119
def __repr__(self):
124-
return "{}.{}({})".format(
125-
__name__,
126-
type(self).__name__,
127-
", ".join("{}={!r}".format(*nv) for nv in zip(self._fields, self)),
128-
)
120+
return f"{__name__}.{type(self).__name__}({', '.join('{}={!r}'.format(*nv) for nv in zip(self._fields, self))})"
129121

130122

131-
__version_info__ = version_info(3, 0, 9, "final", 0)
132-
__version_time__ = "05 May 2022 07:02 UTC"
123+
__version_info__ = version_info(3, 1, 0, "final", 1)
124+
__version_time__ = "18 Jun 2023 14:05 UTC"
133125
__version__ = __version_info__.__version__
134126
__versionTime__ = __version_time__
135127
__author__ = "Paul McGuire <[email protected]>"
@@ -139,9 +131,9 @@ def __repr__(self):
139131
from .actions import *
140132
from .core import __diag__, __compat__
141133
from .results import *
142-
from .core import *
134+
from .core import * # type: ignore[misc, assignment]
143135
from .core import _builtin_exprs as core_builtin_exprs
144-
from .helpers import *
136+
from .helpers import * # type: ignore[misc, assignment]
145137
from .helpers import _builtin_exprs as helper_builtin_exprs
146138

147139
from .unicode import unicode_set, UnicodeRangeList, pyparsing_unicode as unicode
@@ -153,11 +145,11 @@ def __repr__(self):
153145

154146
# define backward compat synonyms
155147
if "pyparsing_unicode" not in globals():
156-
pyparsing_unicode = unicode
148+
pyparsing_unicode = unicode # type: ignore[misc]
157149
if "pyparsing_common" not in globals():
158-
pyparsing_common = common
150+
pyparsing_common = common # type: ignore[misc]
159151
if "pyparsing_test" not in globals():
160-
pyparsing_test = testing
152+
pyparsing_test = testing # type: ignore[misc]
161153

162154
core_builtin_exprs += common_builtin_exprs + helper_builtin_exprs
163155

@@ -174,7 +166,9 @@ def __repr__(self):
174166
"CaselessKeyword",
175167
"CaselessLiteral",
176168
"CharsNotIn",
169+
"CloseMatch",
177170
"Combine",
171+
"DelimitedList",
178172
"Dict",
179173
"Each",
180174
"Empty",
@@ -227,9 +221,11 @@ def __repr__(self):
227221
"alphas8bit",
228222
"any_close_tag",
229223
"any_open_tag",
224+
"autoname_elements",
230225
"c_style_comment",
231226
"col",
232227
"common_html_entity",
228+
"condition_as_parse_action",
233229
"counted_array",
234230
"cpp_style_comment",
235231
"dbl_quoted_string",
@@ -241,6 +237,7 @@ def __repr__(self):
241237
"html_comment",
242238
"identchars",
243239
"identbodychars",
240+
"infix_notation",
244241
"java_style_comment",
245242
"line",
246243
"line_end",
@@ -255,8 +252,12 @@ def __repr__(self):
255252
"null_debug_action",
256253
"nums",
257254
"one_of",
255+
"original_text_for",
258256
"printables",
259257
"punc8bit",
258+
"pyparsing_common",
259+
"pyparsing_test",
260+
"pyparsing_unicode",
260261
"python_style_comment",
261262
"quoted_string",
262263
"remove_quotes",
@@ -267,38 +268,33 @@ def __repr__(self):
267268
"srange",
268269
"string_end",
269270
"string_start",
271+
"token_map",
270272
"trace_parse_action",
273+
"ungroup",
274+
"unicode_set",
271275
"unicode_string",
272276
"with_attribute",
273-
"indentedBlock",
274-
"original_text_for",
275-
"ungroup",
276-
"infix_notation",
277-
"locatedExpr",
278277
"with_class",
279-
"CloseMatch",
280-
"token_map",
281-
"pyparsing_common",
282-
"pyparsing_unicode",
283-
"unicode_set",
284-
"condition_as_parse_action",
285-
"pyparsing_test",
286278
# pre-PEP8 compatibility names
287279
"__versionTime__",
288280
"anyCloseTag",
289281
"anyOpenTag",
290282
"cStyleComment",
291283
"commonHTMLEntity",
284+
"conditionAsParseAction",
292285
"countedArray",
293286
"cppStyleComment",
294287
"dblQuotedString",
295288
"dblSlashComment",
296289
"delimitedList",
297290
"dictOf",
298291
"htmlComment",
292+
"indentedBlock",
293+
"infixNotation",
299294
"javaStyleComment",
300295
"lineEnd",
301296
"lineStart",
297+
"locatedExpr",
302298
"makeHTMLTags",
303299
"makeXMLTags",
304300
"matchOnlyAtCol",
@@ -308,6 +304,7 @@ def __repr__(self):
308304
"nullDebugAction",
309305
"oneOf",
310306
"opAssoc",
307+
"originalTextFor",
311308
"pythonStyleComment",
312309
"quotedString",
313310
"removeQuotes",
@@ -317,15 +314,9 @@ def __repr__(self):
317314
"sglQuotedString",
318315
"stringEnd",
319316
"stringStart",
317+
"tokenMap",
320318
"traceParseAction",
321319
"unicodeString",
322320
"withAttribute",
323-
"indentedBlock",
324-
"originalTextFor",
325-
"infixNotation",
326-
"locatedExpr",
327321
"withClass",
328-
"tokenMap",
329-
"conditionAsParseAction",
330-
"autoname_elements",
331322
]

src/pip/_vendor/pyparsing/actions.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# actions.py
22

33
from .exceptions import ParseException
4-
from .util import col
4+
from .util import col, replaced_by_pep8
55

66

77
class OnlyOnce:
@@ -38,7 +38,7 @@ def match_only_at_col(n):
3838

3939
def verify_col(strg, locn, toks):
4040
if col(locn, strg) != n:
41-
raise ParseException(strg, locn, "matched token not at column {}".format(n))
41+
raise ParseException(strg, locn, f"matched token not at column {n}")
4242

4343
return verify_col
4444

@@ -148,15 +148,13 @@ def pa(s, l, tokens):
148148
raise ParseException(
149149
s,
150150
l,
151-
"attribute {!r} has value {!r}, must be {!r}".format(
152-
attrName, tokens[attrName], attrValue
153-
),
151+
f"attribute {attrName!r} has value {tokens[attrName]!r}, must be {attrValue!r}",
154152
)
155153

156154
return pa
157155

158156

159-
with_attribute.ANY_VALUE = object()
157+
with_attribute.ANY_VALUE = object() # type: ignore [attr-defined]
160158

161159

162160
def with_class(classname, namespace=""):
@@ -195,13 +193,25 @@ def with_class(classname, namespace=""):
195193
1 4 0 1 0
196194
1,3 2,3 1,1
197195
"""
198-
classattr = "{}:class".format(namespace) if namespace else "class"
196+
classattr = f"{namespace}:class" if namespace else "class"
199197
return with_attribute(**{classattr: classname})
200198

201199

202200
# pre-PEP8 compatibility symbols
203-
replaceWith = replace_with
204-
removeQuotes = remove_quotes
205-
withAttribute = with_attribute
206-
withClass = with_class
207-
matchOnlyAtCol = match_only_at_col
201+
# fmt: off
202+
@replaced_by_pep8(replace_with)
203+
def replaceWith(): ...
204+
205+
@replaced_by_pep8(remove_quotes)
206+
def removeQuotes(): ...
207+
208+
@replaced_by_pep8(with_attribute)
209+
def withAttribute(): ...
210+
211+
@replaced_by_pep8(with_class)
212+
def withClass(): ...
213+
214+
@replaced_by_pep8(match_only_at_col)
215+
def matchOnlyAtCol(): ...
216+
217+
# fmt: on

0 commit comments

Comments
 (0)