|
34 | 34 | built-in Python debugger. |
35 | 35 | """ |
36 | 36 |
|
| 37 | +from __future__ import annotations |
| 38 | + |
| 39 | +from collections.abc import Callable |
37 | 40 | import sys |
38 | 41 | import time |
39 | 42 | from reprlib import Repr |
|
47 | 50 | __all__ = ['pdb_on_signal', 'pdb_on_exception', 'wrap_trace'] |
48 | 51 |
|
49 | 52 |
|
50 | | -def pdb_on_signal(signalnum=None): |
| 53 | +def pdb_on_signal(signalnum: int | None = None) -> None: |
51 | 54 | """Installs a signal handler for *signalnum*, which defaults to |
52 | 55 | ``SIGINT``, or keyboard interrupt/ctrl-c. This signal handler |
53 | 56 | launches a :mod:`pdb` breakpoint. Results vary in concurrent |
@@ -75,7 +78,7 @@ def pdb_int_handler(sig, frame): |
75 | 78 | return |
76 | 79 |
|
77 | 80 |
|
78 | | -def pdb_on_exception(limit=100): |
| 81 | +def pdb_on_exception(limit: int = 100) -> None: |
79 | 82 | """Installs a handler which, instead of exiting, attaches a |
80 | 83 | post-mortem pdb console whenever an unhandled exception is |
81 | 84 | encountered. |
@@ -138,8 +141,8 @@ def trace_print_hook(event, label, obj, attr_name, |
138 | 141 | return |
139 | 142 |
|
140 | 143 |
|
141 | | -def wrap_trace(obj, hook=trace_print_hook, |
142 | | - which=None, events=None, label=None): |
| 144 | +def wrap_trace(obj, hook: Callable = trace_print_hook, |
| 145 | + which: str | None = None, events: str | None = None, label: str | None = None): |
143 | 146 | """Monitor an object for interactions. Whenever code calls a method, |
144 | 147 | gets an attribute, or sets an attribute, an event is called. By |
145 | 148 | default the trace output is printed, but a custom tracing *hook* |
|
0 commit comments