Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upImplements module attribute suggestions #7971
Conversation
Thanks for the PR! This will be a nice usability improvement. I'm mostly worried about potential performance impact, otherwise looks good. |
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] |
This comment has been minimized.
This comment has been minimized.
JukkaL
Nov 19, 2019
Collaborator
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"? |
This comment has been minimized.
This comment has been minimized.
JukkaL
Nov 19, 2019
Collaborator
Maybe add a test case where there are multiple possible suggestions?
This comment has been minimized.
This comment has been minimized.
Also, self check seems to be failing (Travis CI). |
This comment has been minimized.
This comment has been minimized.
Hey, I addressed the comments! I wasn't sure what you meant by the |
This comment has been minimized.
This comment has been minimized.
(GitHub did something very weird and I have no idea how to undo this.) |
This comment has been minimized.
This comment has been minimized.
Hm, I never received an email for that comment either |
This comment has been minimized.
This comment has been minimized.
Anyway, I think Jukka meant that you can use the same argument (say |
Thanks, LGTM now! |
theodoretliu commentedNov 18, 2019
Addresses the remainder of issue #824