Fix recursion error for inference of self-referencing class attribute#1392
Fix recursion error for inference of self-referencing class attribute#1392Pierre-Sassoulas merged 4 commits intopylint-dev:mainfrom
Conversation
Pierre-Sassoulas
left a comment
There was a problem hiding this comment.
The actual change looks great, but I don't think we should change the way we currentely import typing and nodes.
|
|
||
| import typing | ||
|
|
||
| from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union |
There was a problem hiding this comment.
It's imported this way in astroid because List, Dict, and Tuple are also astroid.nodes so it can become confusing. It's probably worth it to stay consistent accross the code base.
There was a problem hiding this comment.
In this file we only use 2 nodes and a lot of different typing stuff. That's why I opted to do it the other way around in this file.
I'm fine with reverting!
There was a problem hiding this comment.
Let's keep the old imports (at least for class name that are also astroid nodes).
There was a problem hiding this comment.
Reverted to only import typing.
|
|
||
| from astroid.exceptions import InferenceOverwriteError | ||
| from astroid.nodes import NodeNG | ||
| from astroid import bases, nodes, util |
There was a problem hiding this comment.
There are some circular import in astroid, between files and between packages, I think importing only what's necessary and not whole package will help to understand what is happening in the code if we want to one day handle the issue.
There was a problem hiding this comment.
On the other hand, importing submodules avoid such import errors as we will get notified of those patterns sooner.
But I'll revert if you want me to!
There was a problem hiding this comment.
@cdce8p do you have an opinion ? It's been a long time since I tried to fix those circular imports, all I remember is the pain 😄
Pierre-Sassoulas
left a comment
There was a problem hiding this comment.
Let's worry about circular import when they happen or when we fix them, thank you @DanielNoord
Steps
Description
This will close when merged pylint-dev/pylint#5408.
Type of Changes
Related Issue