Python Patrol β€” Inline PR Fix Suggestions for Python

πŸπŸ” Python Patrol

Static analysis for Python performance anti-patterns & common mistakes β€” with inline PR fix suggestions.

Python Patrol is a zero-dependency GitHub Action that catches bugs and performance issues other linters miss. When it runs on your pull requests, it posts inline review comments with one-click fix suggestions β€” not just warnings, but actual fixes you can apply with a single click.

What Makes It Different?

Ruff and pylint are great. But they run locally and give you a list of warnings. Python Patrol runs in your PR and does something no other linter does well:

  • Inline fix suggestions β€” clickable “Apply suggestion” buttons right on the diff
  • Performance evidence β€” real CPython 3.12 benchmark data explaining why each pattern matters
  • Zero dependencies β€” pure Python ast module, runs in ~100ms

Example

When Python Patrol finds a list membership check like if x in [1, 2, 3], it posts:

🐍 Python Patrol β€” PP002
Membership test against a list literal is O(n) β€” use a set literal instead.
πŸ“Š Why it matters: List membership is O(n) vs O(1) for sets. On a 1000-element collection, set lookup is ~100x faster (CPython 3.12 timeit).
πŸ’‘ Suggested fix: if x in {1, 2, 3}:

15 Rules Across 3 Categories

Performance (PP001–PP006): Mutable defaults, list membership checks, string concat in loops, unnecessary list comprehensions, repeated attribute lookups.

Correctness (PC001–PC005): Bare except, mutable class variables, late-binding closures, assert in production, == None.

Security (PS001–PS003): Hardcoded secrets, eval/exec, pickle on untrusted data.

Quick Start

name: Python Patrol
on: [pull_request]

jobs:
  patrol:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: bBlazewavE/python-patrol@v1
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}

Links

Built with pure Python. No dependencies. Just better code reviews.