This guide helps you set up local development with automated quality checks.
make install
# or
pip install -r requirements-dev.txtmake pre-commit
# or
pip install pre-commit
pre-commit install
pre-commit install --hook-type pre-pushgit config core.hooksPath .githooksmake help # Show all available commands
make format # Format code (black + isort)
make lint # Run linting (flake8 + mypy)
make test # Run tests
make check-all # Run all checks (format + lint + test)
make fix # Format code and run tests
make clean # Clean up temporary files./scripts/test-local.sh # Run all CI checks locally# Format code
black custom_components/wattbox tests/
isort --profile=black custom_components/wattbox tests/
# Check formatting
black --check custom_components/wattbox tests/
isort --check-only --profile=black custom_components/wattbox tests/
# Run linting
flake8 custom_components/wattbox tests/
mypy custom_components/wattbox tests/ --ignore-missing-imports
# Run tests
pytest tests/ --cov=custom_components/wattbox --cov-report=term-missingThe project includes .vscode/settings.json with:
- Auto-formatting on save (Black)
- Auto-import sorting (isort)
- Linting enabled (flake8, mypy)
- Trailing whitespace removal
Configure your IDE to:
- Use Black for Python formatting
- Use isort for import sorting
- Enable flake8 and mypy linting
- Remove trailing whitespace on save
Pre-commit hooks will automatically run checks on:
git commit- Basic checks (formatting, linting)git push- Full checks (formatting, linting, tests)
make check-all
# or
./scripts/test-local.shgit config core.hooksPath .githooks# Reinstall hooks
pre-commit uninstall
pre-commit install
pre-commit install --hook-type pre-push# Auto-fix formatting
make format
# Check what would be changed
make format-check# Run tests with verbose output
pytest tests/ -v --tb=short
# Run specific test file
pytest tests/test_specific.py -vThe GitHub Actions workflow (.github/workflows/ci.yml) runs:
- Format Check:
black --checkandisort --check-only - Linting:
flake8andmypy - Testing:
pytestwith coverage - Security:
banditandsafety
All these checks should pass locally before pushing!