Skip to content
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

Right-click on function to apply annotation suggestions #53

Open
chadrik opened this issue Apr 11, 2020 · 3 comments
Open

Right-click on function to apply annotation suggestions #53

chadrik opened this issue Apr 11, 2020 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@chadrik
Copy link

chadrik commented Apr 11, 2020

Would be great to make use of dmypy suggest to add annotations to existing code.

@ilevkivskyi
Copy link
Contributor

Actually you can already do this in some sense. There is a hidden (or rather just not advertised as official) hot key Ctrl+Shift+Y that will launch a script at ./mypy/mypy-suggest (hardcoded) and pass it current file name and current line number and then reloads the doc. You can write a short script that essentially pipes dmypy suggest to pyannontate -w that will apply the suggestion in-place.

But yeah, making it on right click and more automated would be great.

@ilevkivskyi ilevkivskyi added enhancement New feature or request help wanted Extra attention is needed labels Apr 12, 2020
@chadrik
Copy link
Author

chadrik commented Apr 12, 2020

Actually you can already do this in some sense. There is a hidden (or rather just not advertised as official) hot key Ctrl+Shift+Y that will launch a script at ./mypy/mypy-suggest (hardcoded) and pass it current file name and current line number and then reloads the doc.

I see. I tried this out and it failed with this error:

/bin/bash ./mypy/mypy-suggest: no such file or directory

I started pycharm from a shell where dmypy suggest -h works, and the mypy console in pycharm works correctly as well. Perhaps what's hardwired is not dmypy suggest?

On a related note, I've been playing around with dmypy suggest and it doesn't seem to take the current scope into consideration when generating annotations.

I get something like this:

dmypy suggest mymodule.myfunc
() -> mymodule:Dict[str, mymodule.Dict[str, module.MyClass]]

When I expect something like this:

dmypy suggest mymodule.myfunc
() -> Dict[str, Dict[str, MyClass]]

The annotations produced by dmypy suggest won't work without being fixed up. Is this by design, or a bug, or user error?

@ilevkivskyi
Copy link
Contributor

Perhaps what's hardwired is not dmypy suggest?

Of course it isn't, please read carefully the sentence you quoted.

Is this by design, or a bug, or user error?

I think this is by design. We have been using this extensively internally for long time, and it worked well for pyannotate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants