ref: Run mypy once and collate messages per-file #56
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.
This PR does the following:
PytestMypyFile
at initialization into an object that can run mypy on all files at once. This eliminates duplication of effort that scales with the number of files that any tests exist in. The output messages are collated by file and queried as needed."--no-silence-site-packages",
from the mypy args. This drops the runtime on my test data from ~360s to ~35s from an empty cache.config.cache
to store amypy-cache
inside.pytest_cache/d/
. I have verified that it works to construct a new cache even usingpytest-xdist
where mypy tests ended up on multiple cores. Looks like mypy takes care of multiple processes updating a cache simultaneously. Pytest can be run with--cache-clear
to manually clear the cache. This brings us from ~35s on the first run to ~1s on subsequent runs. Updating my source code invalidates the cache, but reruns take ~17s.MypyResult
. This was mainly because it was simpler to do the rest once I knew what was never read. Those could be restored, but there would at least no longer be a coupling between returncode and the specific file being read, as an error in one file would produce a nonzero returncode for all files.If you're interested, I'm happy to clean this up with any adjustments you'd like. I can also break it up into one PR for each of the above points, if you'd rather consider one thing at a time.
Closes #13.