Search code examples
pythonpre-commit

Are there any pre-commit linters that can stop me from committing code with PySnooper decorators?


I use PySnooper library for debugging. It looks like this:

import pysnooper

@pysnooper.snoop()
def number_to_bits(number):
    ...

I don't want to commit such a code. This @pysnooper library is for debugging only. How to prevent it with pre-commit hooks?


Solution

  • https://github.com/adamchainz/flake8-tidy-imports#banned-modules This linter can do it.

    [flake8]
    banned-modules = pysnooper = remove debugging code!