mirror of
https://github.com/davidhalter/parso.git
synced 2026-02-25 11:07:38 +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: The ancestors of this node will be checked.
|
||||||
:param node_types: type names that are searched for.
|
:param node_types: type names that are searched for.
|
||||||
"""
|
"""
|
||||||
n = node.parent
|
return node.search_ancestor(*node_types)
|
||||||
while n is not None:
|
|
||||||
if n.type in node_types:
|
|
||||||
return n
|
|
||||||
n = n.parent
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
class NodeOrLeaf:
|
class NodeOrLeaf:
|
||||||
|
|||||||
Reference in New Issue
Block a user