-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Implements module attribute suggestions #7971
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.
Thanks for the PR! This will be a nice usability improvement. I'm mostly worried about potential performance impact, otherwise looks good.
mypy/checkexpr.py
Outdated
module_members = None | ||
|
||
if isinstance(base, RefExpr) and isinstance(base.node, MypyFile): | ||
module_members = [key for key in base.node.names.keys() if not base.node.names.get(key).module_hidden] |
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.
This can be expensive to calculate, in case the module has many attributes. Instead of passing the members, what about passing a SymbolTable
object, and calculating the members only later if we generate an error message?
@@ -126,7 +126,7 @@ import m | |||
if int(): | |||
from m import foobaz # E:5: Module 'm' has no attribute 'foobaz'; maybe "foobar"? | |||
(1).x # E:2: "int" has no attribute "x" | |||
(m.foobaz()) # E:2: Module has no attribute "foobaz" | |||
(m.foobaz()) # E:2: Module has no attribute "foobaz"; maybe "foobar"? |
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.
Maybe add a test case where there are multiple possible suggestions?
Also, self check seems to be failing (Travis CI). |
Hey, I addressed the comments! I wasn't sure what you meant by the |
(GitHub did something very weird and I have no idea how to undo this.) |
Hm, I never received an email for that comment either |
Anyway, I think Jukka meant that you can use the same argument (say |
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.
Thanks, LGTM now!
Addresses the remainder of issue #824