3030
3131from  sdb .target  import  type_canonicalize_name , type_canonical_name , type_canonicalize , get_prog 
3232from  sdb .error  import  CommandError , SymbolNotFoundError 
33- import  sdb . target   as  target 
33+ from  sdb   import  target 
3434
3535# 
3636# The register_command is used by the Command class when its 
@@ -45,17 +45,13 @@ def register_command(name: str, class_: Type["Command"]) -> None:
4545    Register the specified command name and command class, such that the 
4646    command will be available from the SDB REPL. 
4747    """ 
48-     # pylint: disable=global-statement 
49-     global  all_commands 
5048    all_commands [name ] =  class_ 
5149
5250
5351def  get_registered_commands () ->  Dict [str , Type ["Command" ]]:
5452    """ 
5553    Return a dictionary of command names to command classes. 
5654    """ 
57-     # pylint: disable=global-statement 
58-     global  all_commands 
5955    return  all_commands 
6056
6157
@@ -108,11 +104,12 @@ def help(cls, name: str) -> None:
108104            # 
109105            if  i  ==  0 :
110106                line  =  line .replace ('usage: ' , '' )
111-             print ("    {}"  . format ( line ) )
107+             print (f "    { line } " 
112108
113109        if  len (cls .names ) >  1 :
110+             aliases  =  ", " .join (cls .names )
114111            print ("ALIASES" )
115-             print ("    {}"  . format ( ", " . join ( cls . names )) )
112+             print (f "    { aliases } " 
116113            print ()
117114
118115        indent  =  "    " 
@@ -168,7 +165,7 @@ def help(cls, name: str) -> None:
168165                    f" case it will consume no objects as input; instead it" 
169166                    f" will locate all objects of type '{ cls .output_type }  
170167                    f" and emit them as output." )
171-             types  =  list () 
168+             types  =  [] 
172169            for  (_ , method ) in  inspect .getmembers (cls , inspect .isroutine ):
173170                if  hasattr (method , "input_typename_handled" ):
174171                    types .append (method .input_typename_handled )
@@ -203,7 +200,7 @@ def help(cls, name: str) -> None:
203200            # 
204201            for  line  in  inspect .getdoc (  # type: ignore[union-attr] 
205202                    cls ).splitlines ()[2 :]:
206-                 print ("{}" . format ( line ) )
203+                 print (f" { line } " 
207204            print ()
208205
209206    # 
@@ -588,12 +585,11 @@ class Walk(Command):
588585    def  _help_message (input_type : drgn .Type  =  None ) ->  str :
589586        msg  =  "" 
590587        if  input_type  is  not None :
591-             msg  =  msg  +  "no walker found for input of type {}\n " .format (
592-                 input_type )
593-         msg  =  msg  +  "The following types have walkers:\n " 
594-         msg  =  msg  +  "\t %-20s %-20s\n "  %  ("WALKER" , "TYPE" )
588+             msg  +=  f"no walker found for input of type { input_type } \n " 
589+         msg  +=  "The following types have walkers:\n " 
590+         msg  +=  f"\t { 'WALKER' :-20s} { 'TYPE' :-20s} \n " 
595591        for  type_ , class_  in  Walker .allWalkers .items ():
596-             msg  =   msg   +   "\t %-20s %-20s \n "    %  ( class_ .names [0 ],  type_ ) 
592+             msg  +=   f "\t { class_ .names [0 ]:-20s }   { type_ :-20s } \n " 
597593        return  msg 
598594
599595    def  _call (self , objs : Iterable [drgn .Object ]) ->  Iterable [drgn .Object ]:
@@ -645,11 +641,12 @@ def _call(self, objs: Iterable[drgn.Object]) -> Iterable[drgn.Object]:
645641        assert  self .input_type  is  not None 
646642        expected_type  =  type_canonicalize_name (self .input_type )
647643        for  obj  in  objs :
648-             if  type_canonical_name (obj .type_ ) !=  expected_type :
644+             canonical_type  =  type_canonical_name (obj .type_ )
645+             if  canonical_type  !=  expected_type :
649646                raise  CommandError (
650647                    self .name ,
651-                     'expected input of type {}, but received {}'  . format ( 
652-                          expected_type ,  type_canonical_name ( obj . type_ )) )
648+                     f 'expected input of type { expected_type } { canonical_type } ' 
649+                 )
653650
654651            yield  from  self .walk (obj )
655652
@@ -724,7 +721,7 @@ def caller(self, objs: Iterable[drgn.Object]) -> Iterable[drgn.Object]:
724721        out_type  =  None 
725722        if  self .output_type  is  not None :
726723            out_type  =  target .get_type (self .output_type )
727-         baked  =  dict () 
724+         baked  =  {} 
728725        for  (_ , method ) in  inspect .getmembers (self , inspect .ismethod ):
729726            if  not  hasattr (method , "input_typename_handled" ):
730727                continue 
@@ -762,8 +759,8 @@ def caller(self, objs: Iterable[drgn.Object]) -> Iterable[drgn.Object]:
762759                    pass 
763760
764761            # error 
765-             raise  CommandError (
766-                 self . name ,  'no handler for input of type {}'  . format ( i .type_ ) )
762+             raise  CommandError (self . name , 
763+                                 f 'no handler for input of type { i .type_ } ' 
767764
768765    def  _call (self ,
769766              objs : Iterable [drgn .Object ]) ->  Optional [Iterable [drgn .Object ]]:
0 commit comments