Skip to content

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented Sep 26, 2025

Description

pylint-dev/pylint#10592

Update node imports to use from astroid import nodes instead.

If we want to, we could consider deprecating the re-export in astroid/__init__.py at some point.

AnnAssign,
Arguments,
Assert,
Assign,
AssignAttr,
AssignName,
AsyncFor,
AsyncFunctionDef,
AsyncWith,
Attribute,
AugAssign,
Await,
BinOp,
BoolOp,
Break,
Call,
ClassDef,
Compare,
Comprehension,
ComprehensionScope,
Const,
Continue,
Decorators,
DelAttr,
Delete,
DelName,
Dict,
DictComp,
DictUnpack,
EmptyNode,
EvaluatedObject,
ExceptHandler,
Expr,
For,
FormattedValue,
FunctionDef,
GeneratorExp,
Global,
If,
IfExp,
Import,
ImportFrom,
Interpolation,
JoinedStr,
Keyword,
Lambda,
List,
ListComp,
Match,
MatchAs,
MatchCase,
MatchClass,
MatchMapping,
MatchOr,
MatchSequence,
MatchSingleton,
MatchStar,
MatchValue,
Module,
Name,
NamedExpr,
NodeNG,
Nonlocal,
ParamSpec,
Pass,
Raise,
Return,
Set,
SetComp,
Slice,
Starred,
Subscript,
TemplateStr,
Try,
TryStar,
Tuple,
TypeAlias,
TypeVar,
TypeVarTuple,
UnaryOp,
Unknown,
While,
With,
Yield,
YieldFrom,

@cdce8p cdce8p added the Maintenance Discussion or action around maintaining astroid or the dev workflow label Sep 26, 2025
Copy link

codecov bot commented Sep 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.36%. Comparing base (0367141) to head (0ec7934).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2833      +/-   ##
==========================================
- Coverage   93.37%   93.36%   -0.01%     
==========================================
  Files          92       92              
  Lines       11148    11139       -9     
==========================================
- Hits        10409    10400       -9     
  Misses        739      739              
Flag Coverage Δ
linux 93.23% <100.00%> (-0.01%) ⬇️
pypy 93.36% <100.00%> (-0.01%) ⬇️
windows 93.34% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
astroid/brain/brain_attrs.py 100.00% <100.00%> (ø)
astroid/brain/brain_functools.py 98.73% <100.00%> (-0.04%) ⬇️
astroid/brain/brain_namedtuple_enum.py 93.52% <100.00%> (-0.03%) ⬇️
astroid/brain/brain_numpy_core_function_base.py 100.00% <100.00%> (ø)
astroid/brain/brain_numpy_core_multiarray.py 100.00% <ø> (ø)
astroid/brain/brain_numpy_core_numeric.py 100.00% <ø> (ø)
astroid/brain/brain_numpy_ndarray.py 100.00% <100.00%> (ø)
astroid/brain/brain_numpy_utils.py 100.00% <100.00%> (ø)
astroid/brain/brain_random.py 85.45% <100.00%> (ø)
astroid/brain/brain_type.py 100.00% <ø> (ø)
... and 7 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. We could probably remove the reexport in 5.0 and add a deprecation now ?

@cdce8p
Copy link
Member Author

cdce8p commented Sep 26, 2025

We could probably remove the reexport in 5.0 and add a deprecation now ?

Sounds good. Will add the deprecation in a separate PR.
Pushed a few more import updates I missed earlier. This is good to go. Though I likely still missed something 😅

Comment on lines -17 to -32
from astroid.nodes import Const
from astroid.nodes.node_classes import (
Interpolation,
Match,
MatchAs,
MatchCase,
MatchClass,
MatchMapping,
MatchOr,
MatchSequence,
MatchSingleton,
MatchStar,
MatchValue,
TemplateStr,
Unknown,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risky to do this in the astroid.nodes package as it's going to easily create circular import, no ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, though I believe it works in this case. We already use the module import.

from astroid import nodes
if TYPE_CHECKING:
from astroid import objects

I don't believe it will but if something crashes, we can still move the import into the type checking block. We'd only need to add back the in-block import for the isinstance check in visit_matchas.

@cdce8p cdce8p merged commit 166f444 into pylint-dev:main Sep 28, 2025
19 checks passed
@cdce8p cdce8p deleted the update-astroid-nodes branch September 28, 2025 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Discussion or action around maintaining astroid or the dev workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants