We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
stderr
ContainerError
str
bytes
% pip list | grep docker docker 7.1.0 types-docker 7.1.0.20240827
from errors.pyi:
errors.pyi
class ContainerError(DockerException): container: Container exit_status: Incomplete command: Incomplete image: Incomplete stderr: str | None def __init__(self, container: Container, exit_status, command, image, stderr: str | None) -> None: ...
While actually, the only source of ContainerError is the following code in containers.py:
containers.py
... out = None if logging_driver == 'json-file' or logging_driver == 'journald': out = container.logs( stdout=stdout, stderr=stderr, stream=True, follow=True ) exit_status = container.wait()['StatusCode'] if exit_status != 0: out = None if not kwargs.get('auto_remove'): out = container.logs(stdout=False, stderr=True) if remove: container.remove() if exit_status != 0: raise ContainerError( container, exit_status, command, image, out ) ...
But, container.logs returns bytes, not string, BUG.
container.logs
That causes mypy false positive in perfectly correct code:
mypy
try: result = client.containers.run( "alpine", f'sh -c "echo hello"', remove=True, stdout=True, stderr=True, ) for line in result.decode("utf-8").split("\n"): print(line) except ContainerError as exc: if exc.stderr: for line in exc.stderr.decode("utf-8").split("\n"): print(line)
% mypy . ... test.py: error: "str" has no attribute "decode"; maybe "encode"? [attr-defined] ...
The text was updated successfully, but these errors were encountered:
No branches or pull requests
% pip list | grep docker docker 7.1.0 types-docker 7.1.0.20240827
from
errors.pyi
:While actually, the only source of
ContainerError
is the following code incontainers.py
:But,
container.logs
returns bytes, not string, BUG.That causes
mypy
false positive in perfectly correct code:The text was updated successfully, but these errors were encountered: