Skip to content

Commit cd68620

Browse files
committed
fix: typing in podman.domain.containers_run
Signed-off-by: dklimpel <[email protected]>
1 parent c9ca28d commit cd68620

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

podman/domain/containers_run.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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[str]]]:
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]

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ module = [
141141
"podman.domain.config",
142142
"podman.domain.containers",
143143
"podman.domain.containers_create",
144-
"podman.domain.containers_run",
145144
"podman.domain.events",
146145
"podman.domain.images_build",
147146
"podman.domain.images_manager",

0 commit comments

Comments
 (0)