Bump pyparsing from 3.1.1 to 3.1.2 (#2296)

* Bump pyparsing from 3.1.1 to 3.1.2

Bumps [pyparsing](https://github.com/pyparsing/pyparsing) from 3.1.1 to 3.1.2.
- [Release notes](https://github.com/pyparsing/pyparsing/releases)
- [Changelog](https://github.com/pyparsing/pyparsing/blob/master/CHANGES)
- [Commits](https://github.com/pyparsing/pyparsing/compare/3.1.1...pyparsing_3.1.2)

---
updated-dependencies:
- dependency-name: pyparsing
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update pyparsing==3.1.2

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>

[skip ci]
This commit is contained in:
dependabot[bot] 2024-03-30 15:28:45 -07:00 committed by GitHub
parent 1d96e0f859
commit 26358427ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 610 additions and 706 deletions

View file

@ -120,8 +120,8 @@ class version_info(NamedTuple):
return f"{__name__}.{type(self).__name__}({', '.join('{}={!r}'.format(*nv) for nv in zip(self._fields, self))})" return f"{__name__}.{type(self).__name__}({', '.join('{}={!r}'.format(*nv) for nv in zip(self._fields, self))})"
__version_info__ = version_info(3, 1, 1, "final", 1) __version_info__ = version_info(3, 1, 2, "final", 1)
__version_time__ = "29 Jul 2023 22:27 UTC" __version_time__ = "06 Mar 2024 07:08 UTC"
__version__ = __version_info__.__version__ __version__ = __version_info__.__version__
__versionTime__ = __version_time__ __versionTime__ = __version_time__
__author__ = "Paul McGuire <ptmcg.gm+pyparsing@gmail.com>" __author__ = "Paul McGuire <ptmcg.gm+pyparsing@gmail.com>"

View file

@ -111,7 +111,6 @@ def with_attribute(*args, **attr_dict):
<div type="graph">1,3 2,3 1,1</div> <div type="graph">1,3 2,3 1,1</div>
<div>this has no type</div> <div>this has no type</div>
</div> </div>
''' '''
div,div_end = make_html_tags("div") div,div_end = make_html_tags("div")
@ -199,19 +198,9 @@ def with_class(classname, namespace=""):
# pre-PEP8 compatibility symbols # pre-PEP8 compatibility symbols
# fmt: off # fmt: off
@replaced_by_pep8(replace_with) replaceWith = replaced_by_pep8("replaceWith", replace_with)
def replaceWith(): ... removeQuotes = replaced_by_pep8("removeQuotes", remove_quotes)
withAttribute = replaced_by_pep8("withAttribute", with_attribute)
@replaced_by_pep8(remove_quotes) withClass = replaced_by_pep8("withClass", with_class)
def removeQuotes(): ... matchOnlyAtCol = replaced_by_pep8("matchOnlyAtCol", match_only_at_col)
@replaced_by_pep8(with_attribute)
def withAttribute(): ...
@replaced_by_pep8(with_class)
def withClass(): ...
@replaced_by_pep8(match_only_at_col)
def matchOnlyAtCol(): ...
# fmt: on # fmt: on

View file

@ -206,7 +206,7 @@ class pyparsing_common:
scientific notation and returns a float""" scientific notation and returns a float"""
# streamlining this expression makes the docs nicer-looking # streamlining this expression makes the docs nicer-looking
number = (sci_real | real | signed_integer).setName("number").streamline() number = (sci_real | real | signed_integer).set_name("number").streamline()
"""any numeric expression, returns the corresponding Python type""" """any numeric expression, returns the corresponding Python type"""
fnumber = ( fnumber = (
@ -216,6 +216,13 @@ class pyparsing_common:
) )
"""any int or real number, returned as float""" """any int or real number, returned as float"""
ieee_float = (
Regex(r"(?i)[+-]?((\d+\.?\d*(e[+-]?\d+)?)|nan|inf(inity)?)")
.set_name("ieee_float")
.set_parse_action(convert_to_float)
)
"""any floating-point literal (int, real number, infinity, or NaN), returned as float"""
identifier = Word(identchars, identbodychars).set_name("identifier") identifier = Word(identchars, identbodychars).set_name("identifier")
"""typical code identifier (leading alpha or '_', followed by 0 or more alphas, nums, or '_')""" """typical code identifier (leading alpha or '_', followed by 0 or more alphas, nums, or '_')"""

File diff suppressed because it is too large Load diff

View file

@ -473,7 +473,7 @@ def _to_diagram_element(
:param show_groups: bool flag indicating whether to show groups using bounding box :param show_groups: bool flag indicating whether to show groups using bounding box
""" """
exprs = element.recurse() exprs = element.recurse()
name = name_hint or element.customName or element.__class__.__name__ name = name_hint or element.customName or type(element).__name__
# Python's id() is used to provide a unique identifier for elements # Python's id() is used to provide a unique identifier for elements
el_id = id(element) el_id = id(element)

View file

@ -14,11 +14,13 @@ from .util import (
from .unicode import pyparsing_unicode as ppu from .unicode import pyparsing_unicode as ppu
class ExceptionWordUnicode(ppu.Latin1, ppu.LatinA, ppu.LatinB, ppu.Greek, ppu.Cyrillic): class _ExceptionWordUnicodeSet(
ppu.Latin1, ppu.LatinA, ppu.LatinB, ppu.Greek, ppu.Cyrillic
):
pass pass
_extract_alphanums = _collapse_string_to_ranges(ExceptionWordUnicode.alphanums) _extract_alphanums = _collapse_string_to_ranges(_ExceptionWordUnicodeSet.alphanums)
_exception_word_extractor = re.compile("([" + _extract_alphanums + "]{1,16})|.") _exception_word_extractor = re.compile("([" + _extract_alphanums + "]{1,16})|.")
@ -86,26 +88,24 @@ class ParseBaseException(Exception):
ret.append(" " * (exc.column - 1) + "^") ret.append(" " * (exc.column - 1) + "^")
ret.append(f"{type(exc).__name__}: {exc}") ret.append(f"{type(exc).__name__}: {exc}")
if depth > 0: if depth <= 0:
return "\n".join(ret)
callers = inspect.getinnerframes(exc.__traceback__, context=depth) callers = inspect.getinnerframes(exc.__traceback__, context=depth)
seen = set() seen = set()
for i, ff in enumerate(callers[-depth:]): for ff in callers[-depth:]:
frm = ff[0] frm = ff[0]
f_self = frm.f_locals.get("self", None) f_self = frm.f_locals.get("self", None)
if isinstance(f_self, ParserElement): if isinstance(f_self, ParserElement):
if not frm.f_code.co_name.startswith( if not frm.f_code.co_name.startswith(("parseImpl", "_parseNoCache")):
("parseImpl", "_parseNoCache")
):
continue continue
if id(f_self) in seen: if id(f_self) in seen:
continue continue
seen.add(id(f_self)) seen.add(id(f_self))
self_type = type(f_self) self_type = type(f_self)
ret.append( ret.append(f"{self_type.__module__}.{self_type.__name__} - {f_self}")
f"{self_type.__module__}.{self_type.__name__} - {f_self}"
)
elif f_self is not None: elif f_self is not None:
self_type = type(f_self) self_type = type(f_self)
@ -220,8 +220,10 @@ class ParseBaseException(Exception):
Example:: Example::
# an expression to parse 3 integers
expr = pp.Word(pp.nums) * 3 expr = pp.Word(pp.nums) * 3
try: try:
# a failing parse - the third integer is prefixed with "A"
expr.parse_string("123 456 A789") expr.parse_string("123 456 A789")
except pp.ParseException as pe: except pp.ParseException as pe:
print(pe.explain(depth=0)) print(pe.explain(depth=0))
@ -244,8 +246,7 @@ class ParseBaseException(Exception):
return self.explain_exception(self, depth) return self.explain_exception(self, depth)
# fmt: off # fmt: off
@replaced_by_pep8(mark_input_line) markInputline = replaced_by_pep8("markInputline", mark_input_line)
def markInputline(self): ...
# fmt: on # fmt: on
@ -255,16 +256,16 @@ class ParseException(ParseBaseException):
Example:: Example::
integer = Word(nums).set_name("integer")
try: try:
Word(nums).set_name("integer").parse_string("ABC") integer.parse_string("ABC")
except ParseException as pe: except ParseException as pe:
print(pe) print(pe)
print("column: {}".format(pe.column)) print(f"column: {pe.column}")
prints:: prints::
Expected integer (at char 0), (line:1, col:1) Expected integer (at char 0), (line:1, col:1) column: 1
column: 1
""" """

View file

@ -74,7 +74,7 @@ def counted_array(
intExpr = intExpr.copy() intExpr = intExpr.copy()
intExpr.set_name("arrayLen") intExpr.set_name("arrayLen")
intExpr.add_parse_action(count_field_parse_action, call_during_try=True) intExpr.add_parse_action(count_field_parse_action, call_during_try=True)
return (intExpr + array_expr).set_name("(len) " + str(expr) + "...") return (intExpr + array_expr).set_name(f"(len) {expr}...")
def match_previous_literal(expr: ParserElement) -> ParserElement: def match_previous_literal(expr: ParserElement) -> ParserElement:
@ -95,15 +95,17 @@ def match_previous_literal(expr: ParserElement) -> ParserElement:
rep = Forward() rep = Forward()
def copy_token_to_repeater(s, l, t): def copy_token_to_repeater(s, l, t):
if t: if not t:
rep << Empty()
return
if len(t) == 1: if len(t) == 1:
rep << t[0] rep << t[0]
else: return
# flatten t tokens # flatten t tokens
tflat = _flatten(t.as_list()) tflat = _flatten(t.as_list())
rep << And(Literal(tt) for tt in tflat) rep << And(Literal(tt) for tt in tflat)
else:
rep << Empty()
expr.add_parse_action(copy_token_to_repeater, callDuringTry=True) expr.add_parse_action(copy_token_to_repeater, callDuringTry=True)
rep.set_name("(prev) " + str(expr)) rep.set_name("(prev) " + str(expr))
@ -230,7 +232,7 @@ def one_of(
if isequal(other, cur): if isequal(other, cur):
del symbols[i + j + 1] del symbols[i + j + 1]
break break
elif masks(cur, other): if masks(cur, other):
del symbols[i + j + 1] del symbols[i + j + 1]
symbols.insert(i, other) symbols.insert(i, other)
break break
@ -534,7 +536,9 @@ def nested_expr(
) )
else: else:
ret <<= Group(Suppress(opener) + ZeroOrMore(ret | content) + Suppress(closer)) ret <<= Group(Suppress(opener) + ZeroOrMore(ret | content) + Suppress(closer))
ret.set_name("nested %s%s expression" % (opener, closer)) ret.set_name(f"nested {opener}{closer} expression")
# don't override error message from content expressions
ret.errmsg = None
return ret return ret
@ -580,7 +584,7 @@ def _makeTags(tagStr, xml, suppress_LT=Suppress("<"), suppress_GT=Suppress(">"))
) )
closeTag = Combine(Literal("</") + tagStr + ">", adjacent=False) closeTag = Combine(Literal("</") + tagStr + ">", adjacent=False)
openTag.set_name("<%s>" % resname) openTag.set_name(f"<{resname}>")
# add start<tagname> results name in parse action now that ungrouped names are not reported at two levels # add start<tagname> results name in parse action now that ungrouped names are not reported at two levels
openTag.add_parse_action( openTag.add_parse_action(
lambda t: t.__setitem__( lambda t: t.__setitem__(
@ -589,7 +593,7 @@ def _makeTags(tagStr, xml, suppress_LT=Suppress("<"), suppress_GT=Suppress(">"))
) )
closeTag = closeTag( closeTag = closeTag(
"end" + "".join(resname.replace(":", " ").title().split()) "end" + "".join(resname.replace(":", " ").title().split())
).set_name("</%s>" % resname) ).set_name(f"</{resname}>")
openTag.tag = resname openTag.tag = resname
closeTag.tag = resname closeTag.tag = resname
openTag.tag_body = SkipTo(closeTag()) openTag.tag_body = SkipTo(closeTag())
@ -777,7 +781,7 @@ def infix_notation(
rpar = Suppress(rpar) rpar = Suppress(rpar)
# if lpar and rpar are not suppressed, wrap in group # if lpar and rpar are not suppressed, wrap in group
if not (isinstance(rpar, Suppress) and isinstance(rpar, Suppress)): if not (isinstance(lpar, Suppress) and isinstance(rpar, Suppress)):
lastExpr = base_expr | Group(lpar + ret + rpar) lastExpr = base_expr | Group(lpar + ret + rpar)
else: else:
lastExpr = base_expr | (lpar + ret + rpar) lastExpr = base_expr | (lpar + ret + rpar)
@ -787,7 +791,7 @@ def infix_notation(
pa: typing.Optional[ParseAction] pa: typing.Optional[ParseAction]
opExpr1: ParserElement opExpr1: ParserElement
opExpr2: ParserElement opExpr2: ParserElement
for i, operDef in enumerate(op_list): for operDef in op_list:
opExpr, arity, rightLeftAssoc, pa = (operDef + (None,))[:4] # type: ignore[assignment] opExpr, arity, rightLeftAssoc, pa = (operDef + (None,))[:4] # type: ignore[assignment]
if isinstance(opExpr, str_type): if isinstance(opExpr, str_type):
opExpr = ParserElement._literalStringClass(opExpr) opExpr = ParserElement._literalStringClass(opExpr)
@ -1058,43 +1062,17 @@ dblSlashComment = dbl_slash_comment
cppStyleComment = cpp_style_comment cppStyleComment = cpp_style_comment
javaStyleComment = java_style_comment javaStyleComment = java_style_comment
pythonStyleComment = python_style_comment pythonStyleComment = python_style_comment
delimitedList = replaced_by_pep8("delimitedList", DelimitedList)
@replaced_by_pep8(DelimitedList) delimited_list = replaced_by_pep8("delimited_list", DelimitedList)
def delimitedList(): ... countedArray = replaced_by_pep8("countedArray", counted_array)
matchPreviousLiteral = replaced_by_pep8("matchPreviousLiteral", match_previous_literal)
@replaced_by_pep8(DelimitedList) matchPreviousExpr = replaced_by_pep8("matchPreviousExpr", match_previous_expr)
def delimited_list(): ... oneOf = replaced_by_pep8("oneOf", one_of)
dictOf = replaced_by_pep8("dictOf", dict_of)
@replaced_by_pep8(counted_array) originalTextFor = replaced_by_pep8("originalTextFor", original_text_for)
def countedArray(): ... nestedExpr = replaced_by_pep8("nestedExpr", nested_expr)
makeHTMLTags = replaced_by_pep8("makeHTMLTags", make_html_tags)
@replaced_by_pep8(match_previous_literal) makeXMLTags = replaced_by_pep8("makeXMLTags", make_xml_tags)
def matchPreviousLiteral(): ... replaceHTMLEntity = replaced_by_pep8("replaceHTMLEntity", replace_html_entity)
infixNotation = replaced_by_pep8("infixNotation", infix_notation)
@replaced_by_pep8(match_previous_expr)
def matchPreviousExpr(): ...
@replaced_by_pep8(one_of)
def oneOf(): ...
@replaced_by_pep8(dict_of)
def dictOf(): ...
@replaced_by_pep8(original_text_for)
def originalTextFor(): ...
@replaced_by_pep8(nested_expr)
def nestedExpr(): ...
@replaced_by_pep8(make_html_tags)
def makeHTMLTags(): ...
@replaced_by_pep8(make_xml_tags)
def makeXMLTags(): ...
@replaced_by_pep8(replace_html_entity)
def replaceHTMLEntity(): ...
@replaced_by_pep8(infix_notation)
def infixNotation(): ...
# fmt: on # fmt: on

View file

@ -173,26 +173,32 @@ class ParseResults:
): ):
self._tokdict: Dict[str, _ParseResultsWithOffset] self._tokdict: Dict[str, _ParseResultsWithOffset]
self._modal = modal self._modal = modal
if name is not None and name != "":
if name is None or name == "":
return
if isinstance(name, int): if isinstance(name, int):
name = str(name) name = str(name)
if not modal: if not modal:
self._all_names = {name} self._all_names = {name}
self._name = name self._name = name
if toklist not in self._null_values:
if toklist in self._null_values:
return
if isinstance(toklist, (str_type, type)): if isinstance(toklist, (str_type, type)):
toklist = [toklist] toklist = [toklist]
if asList: if asList:
if isinstance(toklist, ParseResults): if isinstance(toklist, ParseResults):
self[name] = _ParseResultsWithOffset( self[name] = _ParseResultsWithOffset(ParseResults(toklist._toklist), 0)
ParseResults(toklist._toklist), 0
)
else: else:
self[name] = _ParseResultsWithOffset( self[name] = _ParseResultsWithOffset(ParseResults(toklist[0]), 0)
ParseResults(toklist[0]), 0
)
self[name]._name = name self[name]._name = name
else: return
try: try:
self[name] = toklist[0] self[name] = toklist[0]
except (KeyError, TypeError, IndexError): except (KeyError, TypeError, IndexError):
@ -204,10 +210,10 @@ class ParseResults:
def __getitem__(self, i): def __getitem__(self, i):
if isinstance(i, (int, slice)): if isinstance(i, (int, slice)):
return self._toklist[i] return self._toklist[i]
else:
if i not in self._all_names: if i not in self._all_names:
return self._tokdict[i][-1][0] return self._tokdict[i][-1][0]
else:
return ParseResults([v[0] for v in self._tokdict[i]]) return ParseResults([v[0] for v in self._tokdict[i]])
def __setitem__(self, k, v, isinstance=isinstance): def __setitem__(self, k, v, isinstance=isinstance):
@ -226,7 +232,10 @@ class ParseResults:
sub._parent = self sub._parent = self
def __delitem__(self, i): def __delitem__(self, i):
if isinstance(i, (int, slice)): if not isinstance(i, (int, slice)):
del self._tokdict[i]
return
mylen = len(self._toklist) mylen = len(self._toklist)
del self._toklist[i] del self._toklist[i]
@ -239,14 +248,12 @@ class ParseResults:
removed = list(range(*i.indices(mylen))) removed = list(range(*i.indices(mylen)))
removed.reverse() removed.reverse()
# fixup indices in token dictionary # fixup indices in token dictionary
for name, occurrences in self._tokdict.items(): for occurrences in self._tokdict.values():
for j in removed: for j in removed:
for k, (value, position) in enumerate(occurrences): for k, (value, position) in enumerate(occurrences):
occurrences[k] = _ParseResultsWithOffset( occurrences[k] = _ParseResultsWithOffset(
value, position - (position > j) value, position - (position > j)
) )
else:
del self._tokdict[i]
def __contains__(self, k) -> bool: def __contains__(self, k) -> bool:
return k in self._tokdict return k in self._tokdict
@ -376,7 +383,7 @@ class ParseResults:
""" """
self._toklist.insert(index, ins_string) self._toklist.insert(index, ins_string)
# fixup indices in token dictionary # fixup indices in token dictionary
for name, occurrences in self._tokdict.items(): for occurrences in self._tokdict.values():
for k, (value, position) in enumerate(occurrences): for k, (value, position) in enumerate(occurrences):
occurrences[k] = _ParseResultsWithOffset( occurrences[k] = _ParseResultsWithOffset(
value, position + (position > index) value, position + (position > index)
@ -652,15 +659,23 @@ class ParseResults:
NL = "\n" NL = "\n"
out.append(indent + str(self.as_list()) if include_list else "") out.append(indent + str(self.as_list()) if include_list else "")
if full: if not full:
return "".join(out)
if self.haskeys(): if self.haskeys():
items = sorted((str(k), v) for k, v in self.items()) items = sorted((str(k), v) for k, v in self.items())
for k, v in items: for k, v in items:
if out: if out:
out.append(NL) out.append(NL)
out.append(f"{indent}{(' ' * _depth)}- {k}: ") out.append(f"{indent}{(' ' * _depth)}- {k}: ")
if isinstance(v, ParseResults): if not isinstance(v, ParseResults):
if v: out.append(repr(v))
continue
if not v:
out.append(str(v))
continue
out.append( out.append(
v.dump( v.dump(
indent=indent, indent=indent,
@ -669,40 +684,26 @@ class ParseResults:
_depth=_depth + 1, _depth=_depth + 1,
) )
) )
else: if not any(isinstance(vv, ParseResults) for vv in self):
out.append(str(v)) return "".join(out)
else:
out.append(repr(v))
if any(isinstance(vv, ParseResults) for vv in self):
v = self v = self
incr = " "
nl = "\n"
for i, vv in enumerate(v): for i, vv in enumerate(v):
if isinstance(vv, ParseResults): if isinstance(vv, ParseResults):
out.append( vv_dump = vv.dump(
"\n{}{}[{}]:\n{}{}{}".format(
indent,
(" " * (_depth)),
i,
indent,
(" " * (_depth + 1)),
vv.dump(
indent=indent, indent=indent,
full=full, full=full,
include_list=include_list, include_list=include_list,
_depth=_depth + 1, _depth=_depth + 1,
),
) )
out.append(
f"{nl}{indent}{incr * _depth}[{i}]:{nl}{indent}{incr * (_depth + 1)}{vv_dump}"
) )
else: else:
out.append( out.append(
"\n%s%s[%d]:\n%s%s%s" f"{nl}{indent}{incr * _depth}[{i}]:{nl}{indent}{incr * (_depth + 1)}{vv}"
% (
indent,
(" " * (_depth)),
i,
indent,
(" " * (_depth + 1)),
str(vv),
)
) )
return "".join(out) return "".join(out)

View file

@ -1,8 +1,10 @@
# testing.py # testing.py
from contextlib import contextmanager from contextlib import contextmanager
import re
import typing import typing
from .core import ( from .core import (
ParserElement, ParserElement,
ParseException, ParseException,
@ -49,23 +51,23 @@ class pyparsing_test:
self._save_context["default_whitespace"] = ParserElement.DEFAULT_WHITE_CHARS self._save_context["default_whitespace"] = ParserElement.DEFAULT_WHITE_CHARS
self._save_context["default_keyword_chars"] = Keyword.DEFAULT_KEYWORD_CHARS self._save_context["default_keyword_chars"] = Keyword.DEFAULT_KEYWORD_CHARS
self._save_context[ self._save_context["literal_string_class"] = (
"literal_string_class" ParserElement._literalStringClass
] = ParserElement._literalStringClass )
self._save_context["verbose_stacktrace"] = ParserElement.verbose_stacktrace self._save_context["verbose_stacktrace"] = ParserElement.verbose_stacktrace
self._save_context["packrat_enabled"] = ParserElement._packratEnabled self._save_context["packrat_enabled"] = ParserElement._packratEnabled
if ParserElement._packratEnabled: if ParserElement._packratEnabled:
self._save_context[ self._save_context["packrat_cache_size"] = (
"packrat_cache_size" ParserElement.packrat_cache.size
] = ParserElement.packrat_cache.size )
else: else:
self._save_context["packrat_cache_size"] = None self._save_context["packrat_cache_size"] = None
self._save_context["packrat_parse"] = ParserElement._parse self._save_context["packrat_parse"] = ParserElement._parse
self._save_context[ self._save_context["recursion_enabled"] = (
"recursion_enabled" ParserElement._left_recursion_enabled
] = ParserElement._left_recursion_enabled )
self._save_context["__diag__"] = { self._save_context["__diag__"] = {
name: getattr(__diag__, name) for name in __diag__._all_names name: getattr(__diag__, name) for name in __diag__._all_names
@ -180,7 +182,12 @@ class pyparsing_test:
""" """
run_test_success, run_test_results = run_tests_report run_test_success, run_test_results = run_tests_report
if expected_parse_results is not None: if expected_parse_results is None:
self.assertTrue(
run_test_success, msg=msg if msg is not None else "failed runTests"
)
return
merged = [ merged = [
(*rpt, expected) (*rpt, expected)
for rpt, expected in zip(run_test_results, expected_parse_results) for rpt, expected in zip(run_test_results, expected_parse_results)
@ -189,9 +196,7 @@ class pyparsing_test:
# expected should be a tuple containing a list and/or a dict or an exception, # expected should be a tuple containing a list and/or a dict or an exception,
# and optional failure message string # and optional failure message string
# an empty tuple will skip any result validation # an empty tuple will skip any result validation
fail_msg = next( fail_msg = next((exp for exp in expected if isinstance(exp, str)), None)
(exp for exp in expected if isinstance(exp, str)), None
)
expected_exception = next( expected_exception = next(
( (
exp exp
@ -230,9 +235,18 @@ class pyparsing_test:
) )
@contextmanager @contextmanager
def assertRaisesParseException(self, exc_type=ParseException, msg=None): def assertRaisesParseException(
with self.assertRaises(exc_type, msg=msg): self, exc_type=ParseException, expected_msg=None, msg=None
yield ):
if expected_msg is not None:
if isinstance(expected_msg, str):
expected_msg = re.escape(expected_msg)
with self.assertRaisesRegex(exc_type, expected_msg, msg=msg) as ctx:
yield ctx
else:
with self.assertRaises(exc_type, msg=msg) as ctx:
yield ctx
@staticmethod @staticmethod
def with_line_numbers( def with_line_numbers(

View file

@ -102,17 +102,10 @@ class unicode_set:
all characters in this range that are valid identifier body characters, all characters in this range that are valid identifier body characters,
plus the digits 0-9, and · (Unicode MIDDLE DOT) plus the digits 0-9, and · (Unicode MIDDLE DOT)
""" """
return "".join( identifier_chars = set(
sorted( c for c in cls._chars_for_ranges if ("_" + c).isidentifier()
set(
cls.identchars
+ "0123456789·"
+ "".join(
[c for c in cls._chars_for_ranges if ("_" + c).isidentifier()]
)
)
)
) )
return "".join(sorted(identifier_chars | set(cls.identchars + "0123456789·")))
@_lazyclassproperty @_lazyclassproperty
def identifier(cls): def identifier(cls):

View file

@ -237,7 +237,7 @@ def _flatten(ll: list) -> list:
return ret return ret
def _make_synonym_function(compat_name: str, fn: C) -> C: def replaced_by_pep8(compat_name: str, fn: C) -> C:
# In a future version, uncomment the code in the internal _inner() functions # In a future version, uncomment the code in the internal _inner() functions
# to begin emitting DeprecationWarnings. # to begin emitting DeprecationWarnings.
@ -251,7 +251,7 @@ def _make_synonym_function(compat_name: str, fn: C) -> C:
@wraps(fn) @wraps(fn)
def _inner(self, *args, **kwargs): def _inner(self, *args, **kwargs):
# warnings.warn( # warnings.warn(
# f"Deprecated - use {fn.__name__}", DeprecationWarning, stacklevel=3 # f"Deprecated - use {fn.__name__}", DeprecationWarning, stacklevel=2
# ) # )
return fn(self, *args, **kwargs) return fn(self, *args, **kwargs)
@ -260,7 +260,7 @@ def _make_synonym_function(compat_name: str, fn: C) -> C:
@wraps(fn) @wraps(fn)
def _inner(*args, **kwargs): def _inner(*args, **kwargs):
# warnings.warn( # warnings.warn(
# f"Deprecated - use {fn.__name__}", DeprecationWarning, stacklevel=3 # f"Deprecated - use {fn.__name__}", DeprecationWarning, stacklevel=2
# ) # )
return fn(*args, **kwargs) return fn(*args, **kwargs)
@ -275,10 +275,3 @@ def _make_synonym_function(compat_name: str, fn: C) -> C:
_inner.__kwdefaults__ = None _inner.__kwdefaults__ = None
_inner.__qualname__ = fn.__qualname__ _inner.__qualname__ = fn.__qualname__
return cast(C, _inner) return cast(C, _inner)
def replaced_by_pep8(fn: C) -> Callable[[Callable], C]:
"""
Decorator for pre-PEP8 compatibility synonyms, to link them to the new function.
"""
return lambda other: _make_synonym_function(other.__name__, fn)

View file

@ -32,7 +32,7 @@ plexapi==4.15.10
portend==3.2.0 portend==3.2.0
profilehooks==1.12.0 profilehooks==1.12.0
PyJWT==2.8.0 PyJWT==2.8.0
pyparsing==3.1.1 pyparsing==3.1.2
python-dateutil==2.9.0.post0 python-dateutil==2.9.0.post0
python-twitter==3.5 python-twitter==3.5
pytz==2024.1 pytz==2024.1