diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py index 93a0492a05..11ad7f97fa 100644 --- a/pylint/checkers/typecheck.py +++ b/pylint/checkers/typecheck.py @@ -21,6 +21,7 @@ import astroid.exceptions import astroid.helpers from astroid import arguments, bases, nodes, util +from astroid.nodes import _base_nodes from astroid.typing import InferenceResult, SuccessfulInferenceResult from pylint.checkers import BaseChecker, utils @@ -660,7 +661,7 @@ def _determine_callable( def _has_parent_of_type( node: nodes.Call, node_type: nodes.Keyword | nodes.Starred, - statement: nodes.Statement, + statement: _base_nodes.Statement, ) -> bool: """Check if the given node has a parent of the given type.""" parent = node.parent diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py index eb9d52d4d5..3b6a26db35 100644 --- a/pylint/checkers/utils.py +++ b/pylint/checkers/utils.py @@ -22,7 +22,7 @@ from astroid import TooManyLevelsError, nodes, util from astroid.context import InferenceContext from astroid.exceptions import AstroidError -from astroid.nodes._base_nodes import ImportNode +from astroid.nodes._base_nodes import ImportNode, Statement from astroid.typing import InferenceResult, SuccessfulInferenceResult if TYPE_CHECKING: @@ -1986,7 +1986,7 @@ def is_typing_member(node: nodes.NodeNG, names_to_check: tuple[str, ...]) -> boo @lru_cache -def in_for_else_branch(parent: nodes.NodeNG, stmt: nodes.Statement) -> bool: +def in_for_else_branch(parent: nodes.NodeNG, stmt: Statement) -> bool: """Returns True if stmt is inside the else branch for a parent For stmt.""" return isinstance(parent, nodes.For) and any( else_stmt.parent_of(stmt) or else_stmt == stmt for else_stmt in parent.orelse diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py index b13e25491a..24a2eeaf5d 100644 --- a/pylint/checkers/variables.py +++ b/pylint/checkers/variables.py @@ -850,7 +850,7 @@ def _node_guarded_by_same_test(node: nodes.NodeNG, other_if: nodes.If) -> bool: def _uncertain_nodes_in_except_blocks( found_nodes: list[nodes.NodeNG], node: nodes.NodeNG, - node_statement: nodes.Statement, + node_statement: _base_nodes.Statement, ) -> list[nodes.NodeNG]: """Return any nodes in ``found_nodes`` that should be treated as uncertain because they are in an except block. @@ -1071,7 +1071,7 @@ def _try_in_loop_body( @staticmethod def _recursive_search_for_continue_before_break( - stmt: nodes.Statement, break_stmt: nodes.Break + stmt: _base_nodes.Statement, break_stmt: nodes.Break ) -> bool: """Return True if any Continue node can be found in descendants of `stmt` before encountering `break_stmt`, ignoring any nested loops. @@ -1091,7 +1091,7 @@ def _recursive_search_for_continue_before_break( @staticmethod def _uncertain_nodes_in_try_blocks_when_evaluating_except_blocks( - found_nodes: list[nodes.NodeNG], node_statement: nodes.Statement + found_nodes: list[nodes.NodeNG], node_statement: _base_nodes.Statement ) -> list[nodes.NodeNG]: """Return any nodes in ``found_nodes`` that should be treated as uncertain. @@ -1139,7 +1139,7 @@ def _uncertain_nodes_in_try_blocks_when_evaluating_except_blocks( @staticmethod def _uncertain_nodes_in_try_blocks_when_evaluating_finally_blocks( - found_nodes: list[nodes.NodeNG], node_statement: nodes.Statement + found_nodes: list[nodes.NodeNG], node_statement: _base_nodes.Statement ) -> list[nodes.NodeNG]: uncertain_nodes: list[nodes.NodeNG] = [] ( @@ -2183,8 +2183,8 @@ def _in_lambda_or_comprehension_body( def _is_variable_violation( node: nodes.Name, defnode: nodes.NodeNG, - stmt: nodes.Statement, - defstmt: nodes.Statement, + stmt: _base_nodes.Statement, + defstmt: _base_nodes.Statement, frame: nodes.LocalsDictNodeNG, # scope of statement of node defframe: nodes.LocalsDictNodeNG, base_scope_type: str, @@ -2338,7 +2338,7 @@ def _is_variable_violation( return maybe_before_assign, annotation_return, use_outer_definition @staticmethod - def _maybe_used_and_assigned_at_once(defstmt: nodes.Statement) -> bool: + def _maybe_used_and_assigned_at_once(defstmt: _base_nodes.Statement) -> bool: """Check if `defstmt` has the potential to use and assign a name in the same statement. """ @@ -2380,7 +2380,9 @@ def _is_builtin(self, name: str) -> bool: return name in self.linter.config.additional_builtins or utils.is_builtin(name) @staticmethod - def _is_only_type_assignment(node: nodes.Name, defstmt: nodes.Statement) -> bool: + def _is_only_type_assignment( + node: nodes.Name, defstmt: _base_nodes.Statement + ) -> bool: """Check if variable only gets assigned a type and never a value.""" if not isinstance(defstmt, nodes.AnnAssign) or defstmt.value: return False