@@ -25,7 +25,7 @@ def run(
2525 stderr = False ,
2626 remove : bool = False ,
2727 ** kwargs ,
28- ) -> Union [Container , Union [Generator [str , None , None ], Iterator [str ]]]:
28+ ) -> Union [Container , Union [Generator [bytes , None , None ], Iterator [bytes ]]]:
2929 """Run a container.
3030
3131 By default, run() will wait for the container to finish and return its logs.
@@ -66,20 +66,22 @@ def run(
6666 APIError: when Podman service reports an error
6767 """
6868 if isinstance (image , Image ):
69- image = image .id
69+ image_id = image .id
70+ else :
71+ image_id = image
7072 if isinstance (command , str ):
7173 command = [command ]
7274
7375 try :
74- container = self .create (image = image , command = command , ** kwargs )
76+ container = self .create (image = image_id , command = command , ** kwargs ) # type: ignore[attr-defined]
7577 except ImageNotFound :
76- self .podman_client .images .pull (
77- image ,
78+ self .podman_client .images .pull ( # type: ignore[attr-defined]
79+ image_id ,
7880 auth_config = kwargs .get ("auth_config" ),
7981 platform = kwargs .get ("platform" ),
8082 policy = kwargs .get ("policy" , "missing" ),
8183 )
82- container = self .create (image = image , command = command , ** kwargs )
84+ container = self .create (image = image_id , command = command , ** kwargs ) # type: ignore[attr-defined]
8385
8486 container .start ()
8587 container .reload ()
@@ -116,6 +118,6 @@ def remove_container(container_object: Container) -> None:
116118 container .remove ()
117119
118120 if exit_status != 0 :
119- raise ContainerError (container , exit_status , command , image , log_iter )
121+ raise ContainerError (container , exit_status , command , image_id , log_iter )
120122
121- return log_iter if kwargs .get ("stream" , False ) or log_iter is None else b"" .join (log_iter )
123+ return log_iter if kwargs .get ("stream" , False ) or log_iter is None else b"" .join (log_iter ) # type: ignore[return-value]
0 commit comments