Skip to content

Commit 6062c1d

Browse files
authored
Fix astroid base_nodes imports (#9394)
1 parent 32b2444 commit 6062c1d

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

pylint/checkers/typecheck.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import astroid.exceptions
2222
import astroid.helpers
2323
from astroid import arguments, bases, nodes, util
24+
from astroid.nodes import _base_nodes
2425
from astroid.typing import InferenceResult, SuccessfulInferenceResult
2526

2627
from pylint.checkers import BaseChecker, utils
@@ -660,7 +661,7 @@ def _determine_callable(
660661
def _has_parent_of_type(
661662
node: nodes.Call,
662663
node_type: nodes.Keyword | nodes.Starred,
663-
statement: nodes.Statement,
664+
statement: _base_nodes.Statement,
664665
) -> bool:
665666
"""Check if the given node has a parent of the given type."""
666667
parent = node.parent

pylint/checkers/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from astroid import TooManyLevelsError, nodes, util
2323
from astroid.context import InferenceContext
2424
from astroid.exceptions import AstroidError
25-
from astroid.nodes._base_nodes import ImportNode
25+
from astroid.nodes._base_nodes import ImportNode, Statement
2626
from astroid.typing import InferenceResult, SuccessfulInferenceResult
2727

2828
if TYPE_CHECKING:
@@ -1986,7 +1986,7 @@ def is_typing_member(node: nodes.NodeNG, names_to_check: tuple[str, ...]) -> boo
19861986

19871987

19881988
@lru_cache
1989-
def in_for_else_branch(parent: nodes.NodeNG, stmt: nodes.Statement) -> bool:
1989+
def in_for_else_branch(parent: nodes.NodeNG, stmt: Statement) -> bool:
19901990
"""Returns True if stmt is inside the else branch for a parent For stmt."""
19911991
return isinstance(parent, nodes.For) and any(
19921992
else_stmt.parent_of(stmt) or else_stmt == stmt for else_stmt in parent.orelse

pylint/checkers/variables.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ def _node_guarded_by_same_test(node: nodes.NodeNG, other_if: nodes.If) -> bool:
851851
def _uncertain_nodes_in_except_blocks(
852852
found_nodes: list[nodes.NodeNG],
853853
node: nodes.NodeNG,
854-
node_statement: nodes.Statement,
854+
node_statement: _base_nodes.Statement,
855855
) -> list[nodes.NodeNG]:
856856
"""Return any nodes in ``found_nodes`` that should be treated as uncertain
857857
because they are in an except block.
@@ -1072,7 +1072,7 @@ def _try_in_loop_body(
10721072

10731073
@staticmethod
10741074
def _recursive_search_for_continue_before_break(
1075-
stmt: nodes.Statement, break_stmt: nodes.Break
1075+
stmt: _base_nodes.Statement, break_stmt: nodes.Break
10761076
) -> bool:
10771077
"""Return True if any Continue node can be found in descendants of `stmt`
10781078
before encountering `break_stmt`, ignoring any nested loops.
@@ -1092,7 +1092,7 @@ def _recursive_search_for_continue_before_break(
10921092

10931093
@staticmethod
10941094
def _uncertain_nodes_in_try_blocks_when_evaluating_except_blocks(
1095-
found_nodes: list[nodes.NodeNG], node_statement: nodes.Statement
1095+
found_nodes: list[nodes.NodeNG], node_statement: _base_nodes.Statement
10961096
) -> list[nodes.NodeNG]:
10971097
"""Return any nodes in ``found_nodes`` that should be treated as uncertain.
10981098
@@ -1140,7 +1140,7 @@ def _uncertain_nodes_in_try_blocks_when_evaluating_except_blocks(
11401140

11411141
@staticmethod
11421142
def _uncertain_nodes_in_try_blocks_when_evaluating_finally_blocks(
1143-
found_nodes: list[nodes.NodeNG], node_statement: nodes.Statement
1143+
found_nodes: list[nodes.NodeNG], node_statement: _base_nodes.Statement
11441144
) -> list[nodes.NodeNG]:
11451145
uncertain_nodes: list[nodes.NodeNG] = []
11461146
(
@@ -2184,8 +2184,8 @@ def _in_lambda_or_comprehension_body(
21842184
def _is_variable_violation(
21852185
node: nodes.Name,
21862186
defnode: nodes.NodeNG,
2187-
stmt: nodes.Statement,
2188-
defstmt: nodes.Statement,
2187+
stmt: _base_nodes.Statement,
2188+
defstmt: _base_nodes.Statement,
21892189
frame: nodes.LocalsDictNodeNG, # scope of statement of node
21902190
defframe: nodes.LocalsDictNodeNG,
21912191
base_scope_type: str,
@@ -2339,7 +2339,7 @@ def _is_variable_violation(
23392339
return maybe_before_assign, annotation_return, use_outer_definition
23402340

23412341
@staticmethod
2342-
def _maybe_used_and_assigned_at_once(defstmt: nodes.Statement) -> bool:
2342+
def _maybe_used_and_assigned_at_once(defstmt: _base_nodes.Statement) -> bool:
23432343
"""Check if `defstmt` has the potential to use and assign a name in the
23442344
same statement.
23452345
"""
@@ -2381,7 +2381,9 @@ def _is_builtin(self, name: str) -> bool:
23812381
return name in self.linter.config.additional_builtins or utils.is_builtin(name)
23822382

23832383
@staticmethod
2384-
def _is_only_type_assignment(node: nodes.Name, defstmt: nodes.Statement) -> bool:
2384+
def _is_only_type_assignment(
2385+
node: nodes.Name, defstmt: _base_nodes.Statement
2386+
) -> bool:
23852387
"""Check if variable only gets assigned a type and never a value."""
23862388
if not isinstance(defstmt, nodes.AnnAssign) or defstmt.value:
23872389
return False

0 commit comments

Comments
 (0)