-
Notifications
You must be signed in to change notification settings - Fork 125
fix: typing in podman.domain.containers_run
#599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: typing in podman.domain.containers_run
#599
Conversation
8e8b54a to
f3aa07b
Compare
|
/assign vrothberg |
|
@jwhonce PTAL |
|
/approve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes typing issues in the podman.domain.containers_run module by resolving type inconsistencies and adding type ignore comments where necessary. The changes enable removal of this module from mypy's ignore list.
Key changes:
- Corrected return type annotation to use
Generator[bytes, None, None]instead ofGenerator[str, None, None] - Renamed
imagevariable toimage_idfor clarity after extracting the ID from Image objects - Added type ignore comments for dynamic attribute access
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pyproject.toml | Removed podman.domain.containers_run from mypy ignore list |
| podman/domain/containers_run.py | Fixed return type annotations and variable naming, added type ignore comments for unresolved dynamic attributes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
podman/domain/containers_run.py
Outdated
| remove: bool = False, | ||
| **kwargs, | ||
| ) -> Union[Container, Union[Generator[str, None, None], Iterator[str]]]: | ||
| ) -> Union[Container, Union[Generator[bytes, None, None], Iterator[str]]]: |
Copilot
AI
Oct 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent return types in Union: Generator yields bytes but Iterator yields str. Both should yield the same type for consistency. Consider changing to Union[Container, Union[Generator[bytes, None, None], Iterator[bytes]]].
| ) -> Union[Container, Union[Generator[bytes, None, None], Iterator[str]]]: | |
| ) -> Union[Container, Union[Generator[bytes, None, None], Iterator[bytes]]]: |
| 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] |
Copilot
AI
Oct 15, 2025
There was a problem hiding this comment.
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).
|
@dklimpel Should the Iterator also be updated to return bytes, as copilot suggests? The ignores are acceptable to me. |
I would only fix this one issue. For a decision if the iterator is a str or bytes it needs a deep dive. EDIT: |
Signed-off-by: dklimpel <5740567+dklimpel@users.noreply.github.com>
Signed-off-by: dklimpel <5740567+dklimpel@users.noreply.github.com>
d7259fb to
f5f9a41
Compare
|
LGTM |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dklimpel, inknos, jwhonce The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
fixes: