@@ -634,24 +634,31 @@ def pretty_print(self, objs: Iterable[drgn.Object]) -> None:
634634 # pylint: disable=missing-docstring
635635 raise NotImplementedError
636636
637- def _call ( # type: ignore[return]
638- self ,
639- objs : Iterable [drgn .Object ]) -> Optional [Iterable [drgn .Object ]]:
637+ def check_input_type (self ,
638+ objs : Iterable [drgn .Object ]) -> Iterable [drgn .Object ]:
640639 """
641- This function will call pretty_print() on each input object,
642- verifying the types as we go.
640+ This function acts as a generator, checking that each passed object
641+ matches the input type for the command
643642 """
644-
645643 assert self .input_type is not None
646644 type_name = type_canonicalize_name (self .input_type )
647645 for obj in objs :
648646 if type_canonical_name (obj .type_ ) != type_name :
649647 raise CommandError (
650648 self .name ,
651- f'exepected input of type { self .input_type } , but received '
649+ f'expected input of type { self .input_type } , but received '
652650 f'type { obj .type_ } ' )
651+ yield obj
653652
654- self .pretty_print ([obj ])
653+ def _call ( # type: ignore[return]
654+ self ,
655+ objs : Iterable [drgn .Object ]) -> Optional [Iterable [drgn .Object ]]:
656+ """
657+ This function will call pretty_print() on each input object,
658+ verifying the types as we go.
659+ """
660+ assert self .input_type is not None
661+ self .pretty_print (self .check_input_type (objs ))
655662
656663
657664class Locator (Command ):
0 commit comments