JBKahn / flake8-print

flake8
MIT License
121 stars 21 forks source link

Make flake8-print available as a pre-commit hook? #58

Closed spenserblack closed 2 years ago

spenserblack commented 2 years ago

We've frequently had to catch print statements in PRs that should use loggers, and this seems like exactly the tool we need! :smiley:

However, would it be possible to make this available as a pre-commit hook (docs)? We would want to catch print statements before the commit is created, even if the developer forgets to run flake8 locally.

calumy commented 2 years ago

Flake8-print can be run as part of the flake8 pre-commit hook. Hopefully, adding something like the following to your .pre-commit-config.yaml will work.

  - repo: https://github.com/PyCQA/flake8
    rev: 5.0.4
    hooks:
      - id: flake8
        additional_dependencies:
          - flake8-print
        args: [--config, setup.cfg]

Another option would be to add flake8 and flake8-print to your CI so that you will get a warning if there are print statements present in a PR.

spenserblack commented 2 years ago

Of course! I had completely forgotten about additional_dependencies :facepalm:

Thank you!

(closing as not planned since using this as an additional dependency is probably preferable to making it a separate hook)