JBKahn / flake8-debugger

flake8 debug statement checker
MIT License
41 stars 10 forks source link

Handle builtin `breakpoint` debugger tracing call #16

Closed rafikdraoui closed 4 years ago

rafikdraoui commented 5 years ago

The breakpoint builtin function has been introduced in Python 3.7: https://docs.python.org/3/whatsnew/3.7.html#pep-553-built-in-breakpoint

breakpoint() calls and import of breakpoint from builtins will trigger warnings when running under Python 3.7 or above.

However, this also include calls to user-defined functions named "breakpoint" that shadow the builtin. It could be nice if the following snippet did not trigger a warning, but with the current implementation, it does:

def breakpoint():
    pass
breakpoint()

That said, this is also the case for unorthodox redefinitions of pdb or set_trace. While it could be argued that shadowing breakpoint is more likely than shadowing pdb, I still think that this change is worth to be released as is, since it should cover the vast majority of "regular" uses of breakpoint.

Closes #12