-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Allow passing path/to/file.py:line instead of fully.qualified.name to dmypy suggest #7483
Conversation
Couple observations:
|
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.
Looks great. This will make this a lot better for interactive type uses.
Is the slowdown mostly caused by the extra reload?
Maybe suggest ought to just do a recheck before running?
@@ -285,13 +287,17 @@ def maybe_suggest(self, step: int, server: Server, src: str) -> List[str]: | |||
try_text=try_text, flex_any=flex_any, | |||
callsites=callsites)) | |||
val = res['error'] if 'error' in res else res['out'] + res['err'] | |||
if json: |
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 getting JSON tests working!
modname, tail = target | ||
node = None # type: Optional[SymbolNode] | ||
if ':' in key: | ||
file, line = key.split(':') |
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.
Add a count so a bad argument can't crash the daemon?
It looks like yes, I tried to play with this a bit more, and it looks like penalty is typically a bit lower, around 500ms (interpreted) for mypy self-suggest with some removed signatures. For compiled this would mean something like 1100ms vs 1200ms, so probably not worth it to try to optimize now (it affects only |
This should help with integrations with editors and IDEs, where getting line number of a function might be much easier than the full name.
The implementation in mostly straightforward. I also did a little refactoring to reuse the existing logic efficiently. The only important difference that I introduced after few experiments is that I force reloading of the file before trying to search the function, since even the smallest edit can offset the line number and lead to some weird results.