Skip to content

Commit c48b7d3

Browse files
committed
Use isinstance(v, Token)
1 parent 01c4f42 commit c48b7d3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lark/tree.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
from typing import List, Callable, Iterator, Union, Optional, Generic, TypeVar, TYPE_CHECKING
55

6+
from .lexer import Token
7+
68
if TYPE_CHECKING:
7-
from .lexer import TerminalDef, Token
9+
from .lexer import TerminalDef
810
try:
911
import rich
1012
except ImportError:
@@ -179,7 +181,7 @@ def find_token(self, token_type: str) -> Iterator[_Leaf_T]:
179181
Example:
180182
>>> term_tokens = tree.find_token('TERM')
181183
"""
182-
return self.scan_values(lambda v: not isinstance(v, Tree) and v.type == token_type)
184+
return self.scan_values(lambda v: isinstance(v, Token) and v.type == token_type)
183185

184186
def expand_kids_by_data(self, *data_values):
185187
"""Expand (inline) children with any of the given data values. Returns True if anything changed"""

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy