Monitor external file changes (e.g. git checkout) and trigger workspace re-check
gertvdijk opened this issue ยท 5 comments
Suppose I change VCS branch to a problematic one across several files. Now I have to navigate to open all affected files and only then the mypy errors will be shown. I'd like to have a way to trigger a full-project check and list all the problems.
I'm currently using a custom task with problem matcher etcetera, but that's rather superfluous and duplicating some problems too.
Sorry for replying so late, I didn't notice your issue! Are you sure you're using this extension (as opposed to the mypy functionality built in Microsoft's Python extension)? Because my extension always shows mypy problems for the entire workspace, without needing to open each file. If you still experience the issue, could you please explain how to reproduce it?
Thanks for the reply!
Did not use your extension for a while anymore, decided to give it another go just now. I may have confused it with the output of the Microsoft Python one yeah.
I'm afraid I still experience the same or another issue, not sure, but the whole extension does not seem to work for me.
-
Disable the Mypy linting in the Microsoft Python extension.
-
Make sure your extension is running by checking dmypy is started in VS Code context.
$ ps aux | grep -F dmypy gert 377536 0.4 0.6 438336 198416 ? S 23:43 0:03 /home/gert/repos/purepythonmilter/.direnv/python-3.10.9/bin/python -m mypy.dmypy --status-file /home/gert/.config/Code/User/workspaceStorage/4a16cbdbb95d5ff578467af64efdf5c7/matangover.mypy/dmypy-aab54478ef9b98495291ed14cc32b82318507be3-375014.json run --log-file /home/gert/.config/Code/User/workspaceStorage/4a16cbdbb95d5ff578467af64efdf5c7/matangover.mypy/dmypy-aab54478ef9b98495291ed14cc32b82318507be3.log -- src/ tests/ --show-column-numbers --no-error-summary --no-pretty --no-color-output --python-executable /home/gert/repos/purepythonmilter/.direnv/python-3.10.9/bin/python
This is the correct venv, the log file is empty by the way.
-
Have two git branches:
a
) Running mypy manullay validates OK and currently checked out,b
) the branch with type annotation issues on which mypy produces errors. -
Run
git checkout b
in a separate terminal. -
Find that Pylance reports the errors just fine in an instant, but your extension does not respond at all.
Expected to see a "problem" reported by your extension.
So yeah, it seems completely silent about typing issues now. ๐
Running it manually to be really sure on b
:
$ mypy src/
src/purepythonmilter/server/milterserver.py: note: In member "start_server" of class "MilterServer":
src/purepythonmilter/server/milterserver.py:42:5: error: Function is missing a return type annotation [no-untyped-def]
src/purepythonmilter/server/milterserver.py: note: In function "start_server":
src/purepythonmilter/server/milterserver.py:51:9: error: Function is missing a return type annotation [no-untyped-def]
src/purepythonmilter/api/application.py: note: In member "start_server" of class "PurePythonMilter":
src/purepythonmilter/api/application.py:351:48: error: Argument "port" to "start_server" of "MilterServer" has incompatible type "int"; expected "str" [arg-type]
Found 3 errors in 2 files (checked 25 source files)
FWIW, it happens in this code base: https://github.com/gertvdijk/purepythonmilter with
diff --git .vscode/settings.json .vscode/settings.json
index 3e75a86..63f440b 100644
--- .vscode/settings.json
+++ .vscode/settings.json
@@ -53,4 +53,9 @@
"shellcheck.customArgs": [
"--norc",
],
+ "mypy.runUsingActiveInterpreter": true,
+ "mypy.targets": [
+ "src/",
+ "tests/"
+ ],
}
Perhaps any of my mypy settings is causing this in there?
As a sidenote, I wanted to say that it doesn't start (fails silently) until I restarted VS Code (runtime status = "not yet activated").
Run git checkout b in a separate terminal.
Find that Pylance reports the errors just fine in an instant, but your extension does not respond at all.
Ah, you are referring to detecting file changes made externally (e.g. using git checkout
). Pylance does this by running a filesystem watcher that triggers a re-check. In this extension I haven't implemented a filesystem watcher. You can trigger a complete workspace re-check by saving any Python file, or by reloading the window. I could add a feature to manually re-check as well, filed #68.
As a sidenote, I wanted to say that it doesn't start (fails silently) until I restarted VS Code (runtime status = "not yet activated").
I cannot reproduce that. If I uninstall the Mypy extension completely, reload the window, and then re-install it, it is immediately activated by vscode:
Perhaps you installed it in a workspace that doesn't contain Python files? If yes, then it's expected the extension shouldn't be activated. If you manage to reproduce this please open a new issue with steps to reproduce. Thanks!
Ah, you are referring to detecting file changes made externally (e.g. using
git checkout
). Pylance does this by running a filesystem watcher that triggers a re-check. In this extension I haven't implemented a filesystem watcher.
Ah, that explains a lot.
You can trigger a complete workspace re-check by saving any Python file
I have auto-save enabled already, saving is a no-op I believe.
or by reloading the window.
What do you mean by reloading a window in VS Code?
I could add a feature to manually re-check as well, filed #68.
Cool, thanks!
Perhaps you installed it in a workspace that doesn't contain Python files? If yes, then it's expected the extension shouldn't be activated.
The multi-root workspace consists of several folders, most of them have Python files. Somehow the extension seems to detect a non-Python workspace or something in that case (just guessing)? ๐
If you manage to reproduce this please open a new issue with steps to reproduce. Thanks!
Alright, I will look into this at a later time and report separately. ๐
I have auto-save enabled already, saving is a no-op I believe.
Still, if you press Cmd+S (e.g. after running git checkout) it will trigger a mypy workspace check .
What do you mean by reloading a window in VS Code?
The command "Reload Window" in the palette.
Somehow the extension seems to detect a non-Python workspace or something in that case (just guessing)?
Hmm, that would be a VS Code bug... Thanks for looking into it! I appreciate it.