mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:43 +00:00

## Summary
Fixes #16189.
Only `sys.breakpointhook` is flagged by the upstream linter:
007a745c86/pylint/checkers/stdlib.py (L38)
but I think it makes sense to flag
[`__breakpointhook__`](https://docs.python.org/3/library/sys.html#sys.__breakpointhook__)
too, as suggested in the issue because it
> contain[s] the original value of breakpointhook [...] in case [it
happens] to get replaced with broken or alternative objects.
## Test Plan
New T100 test cases
43 lines
906 B
Python
43 lines
906 B
Python
breakpoint()
|
|
|
|
import pdb
|
|
import builtins
|
|
from builtins import breakpoint
|
|
from pdb import set_trace as st
|
|
from celery.contrib.rdb import set_trace
|
|
from celery.contrib import rdb
|
|
import celery.contrib.rdb
|
|
from debugpy import wait_for_client
|
|
import debugpy
|
|
from ptvsd import break_into_debugger
|
|
from ptvsd import enable_attach
|
|
from ptvsd import wait_for_attach
|
|
import ptvsd
|
|
|
|
breakpoint()
|
|
st()
|
|
set_trace()
|
|
debugpy.breakpoint()
|
|
wait_for_client()
|
|
debugpy.listen(1234)
|
|
enable_attach()
|
|
break_into_debugger()
|
|
wait_for_attach()
|
|
|
|
|
|
# also flag `breakpointhook` from `sys` but obviously not `sys` itself. see
|
|
# https://github.com/astral-sh/ruff/issues/16189
|
|
import sys # ok
|
|
|
|
def scope():
|
|
from sys import breakpointhook # error
|
|
|
|
breakpointhook() # error
|
|
|
|
def scope():
|
|
from sys import __breakpointhook__ # error
|
|
|
|
__breakpointhook__() # error
|
|
|
|
sys.breakpointhook() # error
|
|
sys.__breakpointhook__() # error
|