Skip to content

Conversation

@managedkaos
Copy link
Owner

Summary

This PR adds comprehensive pre-commit hooks to the Python container template to ensure code quality, security, and consistent formatting across all contributions.

Changes Made

New Files Added

  • .pre-commit-config.yaml - Pre-commit configuration with multiple hooks:

    • Code formatting: Black (25.1.0) and isort (6.0.1)
    • Linting: flake8 (7.3.0) for code quality checks
    • Security: bandit (1.8.5) for vulnerability scanning
    • Secret detection: detect-secrets (v1.5.0) for credential scanning
    • General checks: Various pre-commit hooks for merge conflicts, YAML validation, etc.
  • .secrets.baseline - Baseline file for detect-secrets to track known secrets and avoid false positives

Files Modified

  • development-requirements.txt - Added pre-commit and bandit dependencies
  • Makefile - Added new targets:
    • pre-commit-install - Install pre-commit hooks
    • pre-commit-update - Update pre-commit hooks and run checks
    • pre-commit-run - Run pre-commit on all files
    • pre-commit-clean - Remove pre-commit hooks
  • README.md - Added comprehensive documentation for:
    • Development setup instructions
    • Pre-commit hooks overview
    • Available make targets
  • .gitignore - Added exclusions for bandit-report.json and .secrets.baseline

Benefits

  • Automated code quality: Ensures consistent formatting and style across all contributions
  • Security scanning: Automatically detects potential security vulnerabilities and exposed secrets
  • Developer experience: Streamlined setup process with clear documentation
  • Template enhancement: Makes this template more robust for new Python container projects

Usage

After merging, developers can set up pre-commit hooks with:

make pre-commit-install

The hooks will automatically run on every commit, ensuring code quality and security standards are maintained.

Testing

  • All pre-commit hooks pass successfully on the current codebase
  • Configuration is compatible with existing linting setup (pyproject.toml)
  • Make targets work correctly and provide clear feedback

@managedkaos managedkaos merged commit 1bf6e3a into main Jun 23, 2025
6 checks passed
@managedkaos managedkaos deleted the feature/add-pre-commit branch June 23, 2025 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants