Enhancement: Support Git Branch-Based Caching and Pre-Execution Commands
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files, tests, or entry points. First identify where mypy's cache configuration and command execution are handled, then clarify the behavior and scope for branch-specific cache paths and pre-execution commands; done should include agreed options and coverage for both features.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100