-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix a crash when __all__
exists but cannot be inferred
#8741
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Fix a crash when ``__all__`` exists but cannot be inferred. | ||
|
||
Closes #8740 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"""Edge case: __all__ exists in module's locals, but cannot be inferred. | ||
|
||
Other tests for undefined-all-variable in tests/functional/n/names_in__all__.py""" | ||
|
||
__all__ += [] # [undefined-variable] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not well-versed in using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I probably shouldn't have used the word "exists". When >>> from pylint import *
>>> version
'3.0.0b1'
Indeed! >>> import astroid
>>> astroid.__all__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'astroid' has no attribute '__all__'. Did you mean: '__file__'? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Versus >>> pylint.__all__
['__version__', 'version', 'modify_sys_path', 'run_pylint', 'run_symilar', 'run_pyreverse'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
undefined-variable:5:0:5:7::Undefined variable '__all__':UNDEFINED |
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.
Why don't we use
safe_infer
here?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.
Do you know of a way to use a helper with
igetattr
(or to use something besides igetattr, here)?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.
Ah, of course.. Well, seems like we need
safe_igetattr
π