mirror of
https://github.com/davidhalter/parso.git
synced 2026-02-13 13:42:34 +08:00
Avoid duplication of code
This commit is contained in:
@@ -14,12 +14,7 @@ def search_ancestor(node: 'NodeOrLeaf', *node_types: str) -> 'Optional[BaseNode]
|
||||
:param node: The ancestors of this node will be checked.
|
||||
:param node_types: type names that are searched for.
|
||||
"""
|
||||
n = node.parent
|
||||
while n is not None:
|
||||
if n.type in node_types:
|
||||
return n
|
||||
n = n.parent
|
||||
return None
|
||||
return node.search_ancestor(*node_types)
|
||||
|
||||
|
||||
class NodeOrLeaf:
|
||||
|
||||
Reference in New Issue
Block a user