11# -*- coding: utf-8 -*-
2- # Copyright (C) 2009, 2013-2014, 2016, 2022 Rocky Bernstein <rocky@gnu.org>
2+ # Copyright (C) 2009, 2013-2014, 2016, 2022, 2023 Rocky Bernstein <rocky@gnu.org>
33#
44# This program is free software: you can redistribute it and/or modify
55# it under the terms of the GNU General Public License as published by
2222#
2323import signal
2424
25+ from typing import Optional
2526
26- def yes_or_no (b ):
27+
28+ def yes_or_no (b ) -> str :
2729 """Return 'Yes' for True and 'No' for False, and ?? for anything
2830 else."""
2931 if type (b ) != bool :
@@ -33,7 +35,7 @@ def yes_or_no(b):
3335 return "No"
3436
3537
36- def lookup_signame (num ) :
38+ def lookup_signame (num : int ) -> Optional [ str ] :
3739 """Find the corresponding signal name for 'num'. Return None
3840 if 'num' is invalid."""
3941 signames = signal .__dict__
@@ -57,10 +59,10 @@ def lookup_signum(name):
5759 if hasattr (signal , uname ):
5860 return getattr (signal , uname )
5961 return None
60- return # Not reached
62+ return # noqa
6163
6264
63- def canonic_signame (name_num ):
65+ def canonic_signame (name_num ) -> Optional [ str ] :
6466 """Return a signal name for a signal name or signal
6567 number. Return None is name_num is an int but not a valid signal
6668 number and False if name_num is a not number. If name_num is a
@@ -211,7 +213,7 @@ def __init__(self, dbgr, ignore_list=None, default_print=True):
211213 self .action ("SIGINT stop print nostack nopass" )
212214 return
213215
214- def initialize_handler (self , signame ):
216+ def initialize_handler (self , signame : str ):
215217 if signame in fatal_signals :
216218 return False
217219 signum = lookup_signum (signame )
@@ -253,13 +255,13 @@ def initialize_handler(self, signame):
253255 pass
254256 return True
255257
256- def set_signal_replacement (self , signum , handle ):
258+ def set_signal_replacement (self , signum : int , handle ):
257259 """A replacement for signal.signal which chains the signal behind
258260 the debugger's handler"""
259261 signame = lookup_signame (signum )
260262 if signame is None :
261263 self .dbgr .intf [- 1 ].errmsg (
262- ( "%s is not a signal number" " I know about.") % signum
264+ "%s is not a signal number I know about." % signum
263265 )
264266 return False
265267 # Since the intent is to set a handler, we should pass this
@@ -271,7 +273,7 @@ def set_signal_replacement(self, signum, handle):
271273 return True
272274 return False
273275
274- def check_and_adjust_sighandler (self , signame , sigs ):
276+ def check_and_adjust_sighandler (self , signame : str , sigs ):
275277 """
276278 Check to see if a single signal handler that we are interested
277279 in has changed or has not been set initially. On return
0 commit comments