Pre-commit-hook for Python project

Viewed 732

How do I remove print statements in a Python project using pre-commit hook before checking in code to GitHub? Currently, I use black and flake8 pre-commit hooks. But they don't seem to have the option to check and remove print statements before checking in code.

2 Answers

You could use flake8 plugin to check for print statements.

https://pypi.org/project/flake8-print/

Just add to your pre-commit config:

  - repo: https://gitlab.com/pycqa/flake8
    rev: <desired-rev>
    hooks:
      - id: flake8
        additional_dependencies: [flake8-print]
Related