Description
Feature Request
Switching branches during development often causes mypy to invalidate its cache, leading to slow reanalysis. Additionally, branch-specific dependencies may differ, which can result in cache pollution if the environment isn't synchronized after switching branches.
Proposed Solutions
Branch-Specific Caching:
Introduce an option to include the Git branch name in the cache directory path. This would allow switching between branches (e.g., from branch-a to branch-b and back) without losing previously cached data, improving performance and reducing redundant analysis.
Pre-Execution Command:
Add an option to run a custom command before mypy execution. This would enable users to automatically sync dependencies, e.g. using uv pip sync requirements.txt
. Running this command before mypy would ensure the environment matches the branch’s requirements, preventing cache corruption due to mismatched dependencies.
Benefits:
- Faster mypy runs when switching branches.
- Better isolation of cached data per branch.
- Reduced risk of cache pollution from dependency mismatches.
- Improved developer experience with automated environment checks.
Additional Context
If similar functionality exists, guidance on achieving this would be greatly appreciated.
Thank you for considering this feature request.