dropbox / mypy-PyCharm-plugin

A simple plugin that allows running mypy from PyCharm and navigate between errors
Apache License 2.0
313 stars 14 forks source link

Mypy Terminal does not update after saving fixes #19

Open j-walker23 opened 5 years ago

j-walker23 commented 5 years ago

I'm not sure if this is a bug or i'm just super slow.

Once the plugin generates all of the typing errors (which is amaizing by the way, thank you!), the mypy terminal errors will never update no matter what i fix/change.

I feel like this has to be me because no one else has raised this in either open or closed issues but i'm hoping it could be a bug on PyCharm 2018.3 RC.

Is anyone using the latest EAP/RC?

Just to make sure. Are the errors in the terminal suppose to update when i save file changes?

Thanks for any help.

ilevkivskyi commented 5 years ago

This is actually intentional. Currently mypy daemon can be still slow to respond on large code bases (sometimes as slow as 10s) which would make updating on every edit painful. You can still re-run type check manually by hitting Ctrl + Shift + M or pressing the "Run" button.

There is ongoing work to make daemon much faster, after we will add an option to auto-update type checking results.

j-walker23 commented 5 years ago

ahhh! Now it all makes sense. When i first set it up everytime i hit "Run" after the first time it would say it's already running and then crash. So that made me think the Run button was a one time thing. I think it had to do with a config i added because now it's working perfectly when i have it re-check the types.

Thanks for your help!

aolieman commented 5 years ago

In PyCharm 2019.1 I don't seem to be able to re-run the daemon through this plugin. Running it the first time with Ctrl + Shift + M works just fine, but this shortcut has no effect after that.

Should there be a dedicated run button for the mypy terminal? If so, it doesn't display for me. The ordinary run button (with project configurations) runs whatever commands or files have been configured, but this also seems to have no effect on the mypy terminal.

ilevkivskyi commented 5 years ago

Should there be a dedicated run button for the mypy terminal?

Yes, there should be a button. Could you please attach a screenshot?

aolieman commented 5 years ago

Okay, there is a run button in the bottom-right corner of the mypy terminal that I didn't see before. It might have been hidden behind a pycharm notification.

And indeed, the mypy run button works as expected, allowing to re-run. It's just the keyboard shortcut that only works once, until pycharm is fully restarted.

ilevkivskyi commented 5 years ago

@aolieman Could you please provide a bit more details about your system and PyCharm minor version? I just tried this on Mac in PyCharm 2019.1.2 and everything worked correctly.

aolieman commented 5 years ago

Of course: I'm running PyCharm 2019.1.3 on Ubuntu 18.04. PyCharm is installed with snap, and recently updated to the latest minor version. The keyboard shortcut Ctrl + Shift + M didn't work for me in earlier minor versions either. This may be mostly irrelevant, since I just figured out that the issue is caused by PyCharm's keymap settings.

When trying the shortcut again just now, I noticed that this key combo is mapped to something in PyCharm: when the cursor is placed between any kind of brackets in the editor pane, the shortcut toggles the cursor position between the opening and closing bracket. This is listed as "Move Caret to Matching Brace" in the default keymap, and many others (I didn't check them all).

So this is just another hotkey clash, and going by #1 you were already aware of this particular one. I wasn't too bothered by the issue after finding the run button, but it's nice to be able to rerun without having to click since I edited the keymap.

Perhaps you were thrown off by my initial report, that:

Running it the first time with Ctrl + Shift + M works just fine, but this shortcut has no effect after that.

That wasn't entirely accurate. It has to do with pane focus within PyCharm: the hotkey works just fine on a fresh startup, and also when focus is on the project/files pane, regardless of the keymap. The counter-intuitive thing is that I tried to put focus on the Mypy terminal before, but that doesn't take focus away from the editor pane.

ilevkivskyi commented 5 years ago

@aolieman Thanks for investigation! I will raise priority for #1.

devxpy commented 5 years ago

Currently mypy daemon can be still slow to respond on large code bases

Does mypy still suffer from this limitation after the introduction of mypyc?

ilevkivskyi commented 5 years ago

Does mypy still suffer from this limitation after the introduction of mypyc?

It is 5x faster, but still I don't want this to be the default (partially because it is conceptually wrong, mypy is not a linter, partially because we need to figure out what to do if there is a syntax error in the code, which is almost always the case while one types).

syastrov commented 4 years ago

PyCharm can usually already detect syntax errors by itse;f. Maybe the plugin could somehow detect (via PyCharm) that there are no syntax errors and only then run mypy? Or, run mypy and if there are syntax errors, just don't show any output?

ilevkivskyi commented 4 years ago

Maybe the plugin could somehow detect (via PyCharm) that there are no syntax errors and only then run mypy?

Yeah, this was the plan, I just didn't have time to figure out how this would work. If you have time, PRs are very welcome!