|
55 | 55 | SUBPROCESS_POPEN = "subprocess.Popen"
|
56 | 56 | SUBPROCESS_RUN = "subprocess.run"
|
57 | 57 | OPEN_MODULE = "_io"
|
| 58 | +DEBUG_BREAKPOINTS = ("builtins.breakpoint", "sys.breakpointhook", "pdb.set_trace") |
58 | 59 |
|
59 | 60 |
|
60 | 61 | DEPRECATED_MODULES = {
|
@@ -434,6 +435,12 @@ class StdlibChecker(DeprecatedMixin, BaseChecker):
|
434 | 435 | "Using the system default implicitly can create problems on other operating systems. "
|
435 | 436 | "See https://www.python.org/dev/peps/pep-0597/",
|
436 | 437 | ),
|
| 438 | + "W1515": ( |
| 439 | + "Leaving functions creating breakpoints in production code is not recommended", |
| 440 | + "forgotten-debug-statement", |
| 441 | + "Calls to breakpoint(), sys.breakpointhook() and pdb.set_trace() should be removed " |
| 442 | + "from code that is not actively being debugged.", |
| 443 | + ), |
437 | 444 | }
|
438 | 445 |
|
439 | 446 | def __init__(self, linter=None):
|
@@ -495,6 +502,7 @@ def _check_shallow_copy_environ(self, node):
|
495 | 502 | "subprocess-run-check",
|
496 | 503 | "deprecated-class",
|
497 | 504 | "unspecified-encoding",
|
| 505 | + "forgotten-debug-statement", |
498 | 506 | )
|
499 | 507 | def visit_call(self, node):
|
500 | 508 | """Visit a Call node."""
|
@@ -531,6 +539,8 @@ def visit_call(self, node):
|
531 | 539 | self._check_env_function(node, inferred)
|
532 | 540 | elif name == SUBPROCESS_RUN:
|
533 | 541 | self._check_for_check_kw_in_run(node)
|
| 542 | + elif name in DEBUG_BREAKPOINTS: |
| 543 | + self.add_message("forgotten-debug-statement", node=node) |
534 | 544 | self.check_deprecated_method(node, inferred)
|
535 | 545 | except astroid.InferenceError:
|
536 | 546 | return
|
|
0 commit comments