Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions podman/domain/containers_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def run(
stderr=False,
remove: bool = False,
**kwargs,
) -> Union[Container, Union[Generator[str, None, None], Iterator[str]]]:
) -> Union[Container, Union[Generator[bytes, None, None], Iterator[bytes]]]:
"""Run a container.

By default, run() will wait for the container to finish and return its logs.
Expand Down Expand Up @@ -66,20 +66,22 @@ def run(
APIError: when Podman service reports an error
"""
if isinstance(image, Image):
image = image.id
image_id = image.id
else:
image_id = image
if isinstance(command, str):
command = [command]

try:
container = self.create(image=image, command=command, **kwargs)
container = self.create(image=image_id, command=command, **kwargs) # type: ignore[attr-defined]
except ImageNotFound:
self.podman_client.images.pull(
image,
self.podman_client.images.pull( # type: ignore[attr-defined]
image_id,
auth_config=kwargs.get("auth_config"),
platform=kwargs.get("platform"),
policy=kwargs.get("policy", "missing"),
)
container = self.create(image=image, command=command, **kwargs)
container = self.create(image=image_id, command=command, **kwargs) # type: ignore[attr-defined]

container.start()
container.reload()
Expand Down Expand Up @@ -116,6 +118,6 @@ def remove_container(container_object: Container) -> None:
container.remove()

if exit_status != 0:
raise ContainerError(container, exit_status, command, image, log_iter)
raise ContainerError(container, exit_status, command, image_id, log_iter)

return log_iter if kwargs.get("stream", False) or log_iter is None else b"".join(log_iter)
return log_iter if kwargs.get("stream", False) or log_iter is None else b"".join(log_iter) # type: ignore[return-value]
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type: ignore[return-value] comment masks a type mismatch. The return type should be explicitly defined or the function signature should be updated to accurately reflect all possible return types (Container, Generator, Iterator, bytes, or None).

Copilot uses AI. Check for mistakes.
2 changes: 1 addition & 1 deletion podman/errors/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(
exit_status: int,
command: Union[str, list[str]],
image: str,
stderr: Optional[Iterable[str]] = None,
stderr: Optional[Iterable[bytes]] = None,
): # pylint: disable=too-many-positional-arguments
"""Initialize ContainerError.

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ module = [
"podman.domain.config",
"podman.domain.containers",
"podman.domain.containers_create",
"podman.domain.containers_run",
"podman.domain.events",
"podman.domain.images_build",
"podman.domain.images_manager",
Expand Down