python.lang.best-practice.pdb.python-debugger-found

profile photo of semgrepsemgrep
Author
6,393
Download Count*

Importing the python debugger; did you mean to leave this in?

Run Locally

Run in CI

Defintion

rules:
  - id: python-debugger-found
    pattern-either:
      - pattern: import pdb
      - pattern: pdb.set_trace()
    message: Importing the python debugger; did you mean to leave this in?
    severity: WARNING
    languages:
      - python
    metadata:
      category: best-practice
      technology:
        - python
      license: Commons Clause License Condition v1.0[LGPL-2.1-only]

Examples

pdb.py

# ruleid: python-debugger-found
import pdb

# ruleid: python-debugger-found
pdb.set_trace()


def foo():
    # ok: python-debugger-found
    p = not_pdb.set_trace()