from typing import (
Any,
- Callable,
Dict,
Iterator,
List,
return NotImplemented
return self._eq(other)
- __hash__ = None # type: Any # For Py3 compatibility.
-
@property
def prefix(self) -> Text:
raise NotImplementedError
value: Text
fixers_applied: List[Any]
bracket_depth: int
- opening_bracket: "Leaf"
+ # Changed later in brackets.py
+ opening_bracket: Optional["Leaf"] = None
used_names: Optional[Set[Text]]
_prefix = "" # Whitespace and comments preceding this token in the input
lineno: int = 0 # Line where this token starts in the input
context: Optional[Context] = None,
prefix: Optional[Text] = None,
fixers_applied: List[Any] = [],
+ opening_bracket: Optional["Leaf"] = None,
) -> None:
"""
Initializer.
self._prefix = prefix
self.fixers_applied: Optional[List[Any]] = fixers_applied[:]
self.children = []
+ self.opening_bracket = opening_bracket
def __repr__(self) -> str:
"""Return a canonical string representation."""
This reproduces the input source exactly.
"""
- return self.prefix + str(self.value)
+ return self._prefix + str(self.value)
def _eq(self, other) -> bool:
"""Compare two nodes for equality."""
self.value,
(self.prefix, (self.lineno, self.column)),
fixers_applied=self.fixers_applied,
+ opening_bracket=self.opening_bracket,
)
def leaves(self) -> Iterator["Leaf"]:
newcontent = list(content)
for i, item in enumerate(newcontent):
assert isinstance(item, BasePattern), (i, item)
- if isinstance(item, WildcardPattern):
- self.wildcards = True
+ # I don't even think this code is used anywhere, but it does cause
+ # unreachable errors from mypy. This function's signature does look
+ # odd though *shrug*.
+ if isinstance(item, WildcardPattern): # type: ignore[unreachable]
+ self.wildcards = True # type: ignore[unreachable]
self.type = type
self.content = newcontent
self.name = name
r.update(r0)
r.update(r1)
yield c0 + c1, r
-
-
-_Convert = Callable[[Grammar, RawNode], Any]