@@ -96,7 +96,7 @@ def __init__(self, options: Iterable[str]) -> None:
96
96
97
97
def get_output (self ) -> str :
98
98
"""Get the output text from the `DebugControl`."""
99
- return cast (str , self .raw_output .getvalue ())
99
+ return cast (str , self .raw_output .getvalue ()) # type: ignore
100
100
101
101
102
102
class NoDebugging :
@@ -188,9 +188,9 @@ def dump_stack_frames(
188
188
skip : int = 0
189
189
) -> None :
190
190
"""Print a summary of the stack to stdout, or someplace else."""
191
- out = out or sys .stdout
192
- out .write (short_stack (limit = limit , skip = skip + 1 ))
193
- out .write ("\n " )
191
+ fout = out or sys .stdout
192
+ fout .write (short_stack (limit = limit , skip = skip + 1 ))
193
+ fout .write ("\n " )
194
194
195
195
196
196
def clipped_repr (text : str , numchars : int = 50 ) -> str :
@@ -371,17 +371,21 @@ def flush(self) -> None:
371
371
self .outfile .flush ()
372
372
373
373
374
- def log (msg : str , stack : bool = False ) -> None : # pragma: debugging
374
+ def log (msg : str , stack : bool = False ) -> None : # pragma: debugging
375
375
"""Write a log message as forcefully as possible."""
376
376
out = DebugOutputFile .get_one (interim = True )
377
377
out .write (msg + "\n " )
378
378
if stack :
379
379
dump_stack_frames (out = out , skip = 1 )
380
380
381
381
382
- def decorate_methods (decorator , butnot = (), private = False ): # pragma: debugging
382
+ def decorate_methods (
383
+ decorator : Callable [..., Any ],
384
+ butnot : Iterable [str ] = (),
385
+ private : bool = False ,
386
+ ) -> Callable [..., Any ]: # pragma: debugging
383
387
"""A class decorator to apply a decorator to methods."""
384
- def _decorator (cls ):
388
+ def _decorator (cls ): # type: ignore
385
389
for name , meth in inspect .getmembers (cls , inspect .isroutine ):
386
390
if name not in cls .__dict__ :
387
391
continue
@@ -395,10 +399,10 @@ def _decorator(cls):
395
399
return _decorator
396
400
397
401
398
- def break_in_pudb (func ): # pragma: debugging
402
+ def break_in_pudb (func : Callable [..., Any ]) -> Callable [..., Any ]: # pragma: debugging
399
403
"""A function decorator to stop in the debugger for each call."""
400
404
@functools .wraps (func )
401
- def _wrapper (* args , ** kwargs ) :
405
+ def _wrapper (* args : Any , ** kwargs : Any ) -> Any :
402
406
import pudb
403
407
sys .stdout = sys .__stdout__
404
408
pudb .set_trace ()
@@ -416,9 +420,9 @@ def show_calls(
416
420
show_return : bool = False ,
417
421
) -> Callable [..., Any ]: # pragma: debugging
418
422
"""A method decorator to debug-log each call to the function."""
419
- def _decorator (func ) :
423
+ def _decorator (func : Callable [..., Any ]) -> Callable [..., Any ] :
420
424
@functools .wraps (func )
421
- def _wrapper (self , * args , ** kwargs ) :
425
+ def _wrapper (self : Any , * args : Any , ** kwargs : Any ) -> Any :
422
426
oid = getattr (self , OBJ_ID_ATTR , None )
423
427
if oid is None :
424
428
oid = f"{ os .getpid ():08d} { next (OBJ_IDS ):04d} "
0 commit comments