Skip to content

Enhancement: Support Git Branch-Based Caching and Pre-Execution Commands #18526

Open
@martinResearch

Description

@martinResearch

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions