-
Notifications
You must be signed in to change notification settings - Fork 0
Description
🔭 Task Overview
Modify the copier template to conditionally generate pre-commit configuration based on whether the user wants to use Nix for dependency management. When Nix is enabled, use repo: local for Python development tools to ensure consistency with Nix-managed versions. When Nix is not used, keep the current remote repository configuration.
🎯 Objectives
- Add a copier template variable to determine if Nix dependency management is desired
- Generate two different pre-commit configurations based on this choice:
- With Nix: Use
repo: localfor black, isort, ruff, and bandit - Without Nix: Keep current remote repo configuration with version pins
- With Nix: Use
- Ensure both configurations maintain the same functionality and arguments
🔬 Steps or Implementation Details
-
Add copier template variable: Create a boolean variable (e.g.,
use_nix_deps) in the copier configuration to ask users about Nix dependency management -
Template the pre-commit config: Modify
.pre-commit-config.yaml.jinja(or similar) to conditionally generate:- If use_nix_deps = true: Convert black, isort, ruff, bandit to local hooks
- If use_nix_deps = false: Keep existing remote repo configuration
-
Configure local hooks section: For Nix users, generate:
- repo: local hooks: - id: black name: black entry: black language: system types: [python] - id: isort name: isort entry: isort language: system types: [python] args: ["--profile", "black", "--filter-files"] - id: ruff-check name: ruff-check entry: ruff check language: system types: [python] args: ["--ignore", "E501", "--extend-select", "E,W"] - id: bandit name: bandit entry: bandit language: system types: [python] args: ["-ll"]
-
Test both configurations: Verify that both generated configurations work correctly in their respective environments
📝 Additional context (Optional)
This approach allows users to choose their preferred dependency management strategy while ensuring tool version consistency within each approach. Users who opt for Nix will get the benefits of unified tool versions, while users who prefer traditional Python dependency management can continue with the current setup.
The template should clearly explain the trade-offs between the two approaches during the copier questionnaire.