Skip to content

Fix typing of get_node_first_ancestor_of_type() and related method #5686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pylint/checkers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,7 @@ def returns_bool(node: nodes.NodeNG) -> bool:


def get_node_first_ancestor_of_type(
node: nodes.NodeNG, ancestor_type: Union[Type[T_Node], Tuple[Type[T_Node]]]
node: nodes.NodeNG, ancestor_type: Union[Type[T_Node], Tuple[Type[T_Node], ...]]
) -> Optional[T_Node]:
"""Return the first parent node that is any of the provided types (or None)"""
for ancestor in node.node_ancestors():
Expand All @@ -1725,7 +1725,7 @@ def get_node_first_ancestor_of_type(


def get_node_first_ancestor_of_type_and_its_child(
node: nodes.NodeNG, ancestor_type: Union[Type[T_Node], Tuple[Type[T_Node]]]
node: nodes.NodeNG, ancestor_type: Union[Type[T_Node], Tuple[Type[T_Node], ...]]
) -> Union[Tuple[None, None], Tuple[T_Node, nodes.NodeNG]]:
"""Modified version of get_node_first_ancestor_of_type to also return the
descendant visited directly before reaching the sought ancestor. Useful
Expand Down