-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Look into using mypy's daemon #1577
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
Comments
Looks like as of June 2018 work has begun for Windows daemon support. |
FYI, mypy master now has a working implementation of the mypy daemon for Windows if you want to play with it. |
How would we be able to use |
@erichiller Until there is more official support, as a work around you can use something like the following:
Though this is rather hackish. (It won't kill the daemon when VS Code closes, which likely is not the behavior you want). Also this is rather abusing the whole "set an executable and args" settings system... Do note you must change the argument for following imports to either skip or error for now. |
@erichiller we would like to add support, but we don't have any ETA on when this will get prioritized high enough for us to get around to it. @ethanhs thanks for the work-around! |
Thanks for connecting with us at PyCon, looking forward to landing this in the extension. Lets get the ball rolling.
|
I think the simplest way is to set current working directory to the repo root when calling
No it will not die. Process created by
Mypy only supports Python 3.5+, it can type check older versions (including 2.7), but you need to have Python 3 installed to run it. If you want to type check a repo in Python 2 mode and then in Python 3 mode, I think the best way is to start two daemons each one configured with
Currently this is not possible.
It is not how mypy normally works (not only the daemon), see #5587. I actually believe we should figure out that issue first before continuing here. |
For anyone wanting this now I actually made two extensions (though I'm very happy to see this will be integrated into the Python extension).
|
And the daemon is now hit GA: https://mypy-lang.blogspot.com/2019/11/mypy-0.html |
I would love to be using the mypy daemon with VS Code. If I can get this to work it will likely become standard for 500+ data scientists at my current employer. VS Code & MyPy are already recommended "best practice", but having the two play nicely together with the daemon would be great (yes, standard MyPy linting response times are a problem for us). I have experimented with the @matangover language server variant but abandoned it an hour ago due to various complexities & problems. FWIW I've been using MyPy extensively for about 18 months and have run several internal trainings on its use within my current organization. We've also seen a general shift from PyCharm to VS Code. In this setting my user-centric view of what I'd like to happen:
|
In parallel to my input on what I'd like best from VSCode-Python listed above, I posted on SO to ask for clarification on the current options around Python + MyPy + LanguageServer in VS Code: |
@ijstokes thanks for the feedback! Please make sure to 👍 the opening comment to make sure your preferences of how we prioritize our time are taken into consideration. |
@ijstokes Your link is broken. Would love to read that |
@JosXa here is the text from that deleted SO question:
|
This doesn't work for me. Here's the Python extension's output:
Looks like it's changed how it does |
At the risk of asking a dumb question, if I can get |
I believe that (non daemon) mypy must start up and re-read any cached data before beginning to work on the files you pass it, which takes some time. In contrast the daemon remains in memory and has no startup cost for runs after the first, so it should return results much faster. |
@rben01 Your not even getting that far.
This means mypy is not being found at all. Like because it isn't installed in the python virtual environment you are running in. Ran into the same thing myself under different circumstances. |
@ijstokes FWIW I implemented most of what you asked for in my mypy extension a few months ago. It now runs the mypy daemon directly for each workspace folder. I also added the |
I opened a ticket to upgrade dmypy to a language server a while back. I guess that could be relevant for this as well: |
Any updates? |
This dev container template uses the daemon: https://github.com/JamesHutchison/python-dev-container-template I agree that the daemon makes more sense in general, however the daemon has also been somewhat "semi-experimental" as it runs a different code path so I can understand being hesitant to use it by default. If your repo is very large and has a very large number of errors, both mypy and dmypy are atrociously slow. This is because the daemon uses errors as a signal to reprocess a file, even if it wasn't touched. |
We now have a preview version of |
@karthiknadig just a heads up, using dmypy by default for vscode may cause bugs like this to surface, causing users problems: python/mypy#12249 |
@tusharsadhwani The extension allows you to configure it to run using |
Closing this against https://marketplace.visualstudio.com/items?itemName=ms-python.mypy-type-checker FYI, that extension allows you to switch between |
https://mypy.readthedocs.io/en/latest/mypy_daemon.html
The text was updated successfully, but these errors were encountered: