Add __slots__ to third-party packages using stubdefaulter (#14619)

This commit is contained in:
Jelle Zijlstra
2025-08-21 15:38:13 -07:00
committed by GitHub
parent 573b57d8da
commit ca44e4c45d
135 changed files with 675 additions and 25 deletions
@@ -21,6 +21,7 @@ def expression(callable: _CALLABLE_TYPE, rule_name: str, grammar: Grammar) -> Ex
IN_PROGRESS: object
class Expression(StrAndRepr):
__slots__ = ["name", "identity_tuple"]
name: str
identity_tuple: tuple[str]
def __init__(self, name: str = "") -> None: ...
@@ -31,6 +32,7 @@ class Expression(StrAndRepr):
def as_rule(self) -> str: ...
class Literal(Expression):
__slots__ = ["literal"]
literal: str
identity_tuple: tuple[str, str] # type: ignore[assignment]
def __init__(self, literal: str, name: str = "") -> None: ...
@@ -38,6 +40,7 @@ class Literal(Expression):
class TokenMatcher(Literal): ...
class Regex(Expression):
__slots__ = ["re"]
re: Pattern[str]
identity_tuple: tuple[str, Pattern[str]] # type: ignore[assignment]
def __init__(
@@ -54,6 +57,7 @@ class Regex(Expression):
) -> None: ...
class Compound(Expression):
__slots__ = ["members"]
members: collections.abc.Sequence[Expression]
def __init__(self, *members: Expression, **kwargs: Any) -> None: ...
@@ -61,12 +65,14 @@ class Sequence(Compound): ...
class OneOf(Compound): ...
class Lookahead(Compound):
__slots__ = ["negativity"]
negativity: bool
def __init__(self, member: Expression, *, negative: bool = False, **kwargs: Any) -> None: ...
def Not(term: Expression) -> Lookahead: ...
class Quantifier(Compound):
__slots__ = ["min", "max"]
min: int
max: float
def __init__(self, member: Expression, *, min: int = 0, max: float = ..., name: str = "", **kwargs: Any) -> None: ...
@@ -8,6 +8,7 @@ from parsimonious.expressions import Expression
from parsimonious.grammar import Grammar
class Node:
__slots__ = ["expr", "full_text", "start", "end", "children"]
expr: Expression
full_text: str
start: int
@@ -25,6 +26,7 @@ class Node:
def __repr__(self, top_level: bool = True) -> str: ...
class RegexNode(Node):
__slots__ = ["match"]
match: Match[str]
class RuleDecoratorMeta(type): ...
@@ -6,5 +6,6 @@ class StrAndRepr: ...
def evaluate_string(string: str | ast.AST) -> Any: ...
class Token(StrAndRepr):
__slots__ = ["type"]
type: str
def __init__(self, type: str) -> None: ...