The Sourcery Pre-Commit Hook

With the Sourcery pre-commit hook, you can:

  • set up automated code quality checks for every commit
  • review your code before you send it to a human reviewer
  • set up the same quality gates as in your CI system

screenshot Sourcery pre-commit hook failed

The recommended setup for a pre-commit hook:

{# x-release-please-start-version #}

  - repo:
    rev: v1.10.0
      - id: sourcery
        # The best way to use Sourcery in a pre-commit hook:
        # * review only changed lines:
        # * omit the summary
        args: [--diff=git diff HEAD, --no-summary]

{# x-release-please-end #}

For more details and configuration options, check out the Getting Started with pre-commit guide.