CI & Pre-Commit Hook
repos: - repo: https://github.com/sourcery-ai/sourcery rev: v0.8.0 # Get the latest tag from https://github.com/sourcery-ai/sourcery/tags hooks: - id: sourcery # - args: [--in-place] Automatically apply the refactorings in the hook
Then run pre-commit install and you're ready to go.
Here's a script to run Sourcery in CI that will fail the job if any refactorings are found:
# Install sourcery pip install sourcery-cli # Login - store SOURCERY_TOKEN in a secret/masked environment variable sourcery login --token $SOURCERY_TOKEN # Find changed files and pass them to Sourcery git diff main --diff-filter=AMR --name-only | xargs sourcery refactor --check