-
-
Notifications
You must be signed in to change notification settings - Fork 294
Fix recursion error for inference of self-referencing class attribute #1392
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual change looks great, but I don't think we should change the way we currentely import typing and nodes.
astroid/inference_tip.py
Outdated
@@ -3,16 +3,20 @@ | |||
|
|||
"""Transform utilities (filters and decorator)""" | |||
|
|||
import typing | |||
|
|||
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the old imports (at least for class name that are also astroid nodes).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted to only import typing
.
astroid/inference_tip.py
Outdated
|
||
import wrapt | ||
|
||
from astroid.exceptions import InferenceOverwriteError | ||
from astroid.nodes import NodeNG | ||
from astroid import bases, nodes, util |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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