Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #13033
This PR adds the
dmypy watch
command. It is basically the same as repeatedly runningdmypy check FILES
and then sleeping for X (defaults to 1) seconds. Here is a short video of it in action:Screen.Recording.2025-04-27.at.20.50.36.mov
I wrote a new non-data-driven test that takes about 10s to complete on my local machine. I don't think an implementation in
daemon.test
would have been as readable, so I resorted to a classicunittest.TestCase
.Alternatives
This polling approach is quite simple and maybe a bit naive, but it works without introducing additional dependencies. For large projects, I assume that listening to filesystem events and only re-checking changed files (with some debouncing logic) is a better fit.
Since Python does not offer a builtin, cross-platform solution for listening to filesystem events, one would need to use third-party dependencies like
watchdog
to solve this, e.g. as an optional dependency. If it is installed, one could use a the more efficient approach, otherwise fall back to the simple polling approach. However, this is outside of the scope of this PR.