Skip to content

Commit 65c4ddf

Browse files
author
Kevin Kirsche
authored
Update parsimonious to 0.10.0 (#8730)
1 parent 3ec7b1f commit 65c4ddf

File tree

6 files changed

+36
-24
lines changed

6 files changed

+36
-24
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
parsimonious.nodes.Node.__repr__
21
parsimonious.nodes.RuleDecoratorMeta.__new__

stubs/parsimonious/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "0.9.*"
1+
version = "0.10.*"

stubs/parsimonious/parsimonious/exceptions.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class ParseError(StrAndRepr, Exception):
1111
def line(self) -> int: ...
1212
def column(self) -> int: ...
1313

14+
class LeftRecursionError(ParseError): ...
1415
class IncompleteParseError(ParseError): ...
1516

1617
class VisitationError(Exception):

stubs/parsimonious/parsimonious/expressions.pyi

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import collections.abc
2+
from _typeshed import Self
23
from collections.abc import Callable, Mapping
34
from re import Pattern
45
from typing import Any, Union
@@ -9,20 +10,22 @@ from parsimonious.grammar import Grammar
910
from parsimonious.nodes import Node
1011
from parsimonious.utils import StrAndRepr
1112

12-
MARKER: Any
13-
1413
_CALLABLE_RETURN_TYPE: TypeAlias = Union[int, tuple[int, list[Node]], Node, None]
1514
_CALLABLE_TYPE: TypeAlias = (
1615
Callable[[str, int], _CALLABLE_RETURN_TYPE]
1716
| Callable[[str, int, Mapping[tuple[int, int], Node], ParseError, Grammar], _CALLABLE_RETURN_TYPE]
1817
)
1918

19+
def is_callable(value: object) -> bool: ...
2020
def expression(callable: _CALLABLE_TYPE, rule_name: str, grammar: Grammar) -> Expression: ...
2121

22+
IN_PROGRESS: object
23+
2224
class Expression(StrAndRepr):
2325
name: str
2426
identity_tuple: tuple[str]
2527
def __init__(self, name: str = ...) -> None: ...
28+
def resolve_refs(self: Self, rule_map: Mapping[str, Expression]) -> Self: ...
2629
def parse(self, text: str, pos: int = ...) -> Node: ...
2730
def match(self, text: str, pos: int = ...) -> Node: ...
2831
def match_core(self, text: str, pos: int, cache: Mapping[tuple[int, int], Node], error: ParseError) -> Node: ...
@@ -57,11 +60,18 @@ class Compound(Expression):
5760

5861
class Sequence(Compound): ...
5962
class OneOf(Compound): ...
60-
class Lookahead(Compound): ...
61-
class Not(Compound): ...
62-
class Optional(Compound): ...
63-
class ZeroOrMore(Compound): ...
6463

65-
class OneOrMore(Compound):
64+
class Lookahead(Compound):
65+
negativity: bool
66+
def __init__(self, member: Expression, *, negative: bool = ..., **kwargs: Any) -> None: ...
67+
68+
def Not(term: Expression) -> Lookahead: ...
69+
70+
class Quantifier(Compound):
6671
min: int
67-
def __init__(self, member: Expression, name: str = ..., min: int = ...) -> None: ...
72+
max: float
73+
def __init__(self, member: Expression, *, min: int = ..., max: float = ..., name: str = ..., **kwargs: Any) -> None: ...
74+
75+
def ZeroOrMore(member: Expression, name: str = ...) -> Quantifier: ...
76+
def OneOrMore(member: Expression, name: str = ..., min: int = ...) -> Quantifier: ...
77+
def Optional(member: Expression, name: str = ...) -> Quantifier: ...

stubs/parsimonious/parsimonious/grammar.pyi

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from collections import OrderedDict
33
from collections.abc import Callable, Mapping
44
from typing import Any, NoReturn
55

6-
from parsimonious.expressions import _CALLABLE_TYPE, Expression, Literal, Lookahead, Not, OneOf, Regex, Sequence, TokenMatcher
6+
from parsimonious.expressions import _CALLABLE_TYPE, Expression, Literal, Lookahead, OneOf, Regex, Sequence, TokenMatcher
77
from parsimonious.nodes import Node, NodeVisitor
88

99
class Grammar(OrderedDict[str, Expression]):
@@ -20,6 +20,7 @@ rule_syntax: str
2020

2121
class LazyReference(str):
2222
name: str
23+
def resolve_refs(self, rule_map: Mapping[str, Expression | LazyReference]) -> Expression: ...
2324

2425
class RuleVisitor(NodeVisitor):
2526
quantifier_classes: dict[str, type[Expression]]
@@ -28,24 +29,24 @@ class RuleVisitor(NodeVisitor):
2829
visit_atom: Callable[[RuleVisitor, Node, collections.abc.Sequence[Any]], Any]
2930
custom_rules: dict[str, Expression]
3031
def __init__(self, custom_rules: Mapping[str, Expression] | None = ...) -> None: ...
31-
def visit_rules(
32-
self, node: Node, rules_list: collections.abc.Sequence[Any]
33-
) -> tuple[OrderedDict[str, Expression], Expression | None]: ...
32+
def visit_parenthesized(self, node: Node, parenthesized: collections.abc.Sequence[Any]) -> Expression: ...
33+
def visit_quantifier(self, node: Node, quantifier: collections.abc.Sequence[Any]) -> Node: ...
34+
def visit_quantified(self, node: Node, quantified: collections.abc.Sequence[Any]) -> Expression: ...
35+
def visit_lookahead_term(self, node: Node, lookahead_term: collections.abc.Sequence[Any]) -> Lookahead: ...
36+
def visit_not_term(self, node: Node, not_term: collections.abc.Sequence[Any]) -> Lookahead: ...
3437
def visit_rule(self, node: Node, rule: collections.abc.Sequence[Any]) -> Expression: ...
35-
def visit_label(self, node: Node, label: collections.abc.Sequence[Any]) -> str: ...
38+
def visit_sequence(self, node: Node, sequence: collections.abc.Sequence[Any]) -> Sequence: ...
3639
def visit_ored(self, node: Node, ored: collections.abc.Sequence[Any]) -> OneOf: ...
3740
def visit_or_term(self, node: Node, or_term: collections.abc.Sequence[Any]) -> Expression: ...
38-
def visit_sequence(self, node: Node, sequence: collections.abc.Sequence[Any]) -> Sequence: ...
39-
def visit_not_term(self, node: Node, not_term: collections.abc.Sequence[Any]) -> Not: ...
40-
def visit_lookahead_term(self, node: Node, lookahead_term: collections.abc.Sequence[Any]) -> Lookahead: ...
41-
def visit_quantified(self, node: Node, quantified: collections.abc.Sequence[Any]) -> Expression: ...
42-
def visit_quantifier(self, node: Node, quantifier: collections.abc.Sequence[Any]) -> Node: ...
41+
def visit_label(self, node: Node, label: collections.abc.Sequence[Any]) -> str: ...
4342
def visit_reference(self, node: Node, reference: collections.abc.Sequence[Any]) -> LazyReference: ...
44-
def visit_literal(self, node: Node, literal: collections.abc.Sequence[Any]) -> Literal: ...
45-
def visit_spaceless_literal(self, spaceless_literal: Node, visited_children: collections.abc.Sequence[Any]) -> Literal: ...
4643
def visit_regex(self, node: Node, regex: collections.abc.Sequence[Any]) -> Regex: ...
47-
def visit_parenthesized(self, node: Node, parenthesized: collections.abc.Sequence[Any]) -> Expression: ...
44+
def visit_spaceless_literal(self, spaceless_literal: Node, visited_children: collections.abc.Sequence[Any]) -> Literal: ...
45+
def visit_literal(self, node: Node, literal: collections.abc.Sequence[Any]) -> Literal: ...
4846
def generic_visit(self, node: Node, visited_children: collections.abc.Sequence[Any]) -> collections.abc.Sequence[Any] | Node: ... # type: ignore[override]
47+
def visit_rules(
48+
self, node: Node, rules_list: collections.abc.Sequence[Any]
49+
) -> tuple[OrderedDict[str, Expression], Expression | None]: ...
4950

5051
class TokenRuleVisitor(RuleVisitor):
5152
def visit_spaceless_literal(

stubs/parsimonious/parsimonious/nodes.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Node:
1919
@property
2020
def text(self) -> str: ...
2121
def prettily(self, error: Node | None = ...) -> str: ...
22+
def __repr__(self, top_level: bool = ...) -> str: ...
2223

2324
class RegexNode(Node):
2425
match: Match[str]
@@ -27,7 +28,7 @@ class RuleDecoratorMeta(type): ...
2728

2829
class NodeVisitor(metaclass=RuleDecoratorMeta):
2930
grammar: Grammar | Any
30-
unwrapped_exceptions: tuple[type[Exception], ...]
31+
unwrapped_exceptions: tuple[type[BaseException], ...]
3132
def visit(self, node: Node) -> Any: ...
3233
def generic_visit(self, node: Node, visited_children: Sequence[Any]) -> NoReturn: ...
3334
def parse(self, text: str, pos: int = ...) -> Node: ...

0 commit comments

Comments
 (0)