diff --git a/docker/context/context.py b/docker/context/context.py index 4faf8e701..9d465498a 100644 --- a/docker/context/context.py +++ b/docker/context/context.py @@ -175,7 +175,7 @@ def remove(self): def __repr__(self): return f"<{self.__class__.__name__}: '{self.name}'>" - def __str__(self): + def __str__(self) -> str: return json.dumps(self.__call__(), indent=2) def __call__(self): diff --git a/docker/errors.py b/docker/errors.py index d03e10f69..72177f831 100644 --- a/docker/errors.py +++ b/docker/errors.py @@ -50,7 +50,7 @@ def __init__(self, message, response=None, explanation=None): self.response = response self.explanation = explanation - def __str__(self): + def __str__(self) -> str: message = super().__str__() if self.is_client_error(): @@ -121,7 +121,7 @@ class TLSParameterError(DockerException): def __init__(self, msg): self.msg = msg - def __str__(self): + def __str__(self) -> str: return self.msg + (". TLS configurations should map the Docker CLI " "client configurations. See " "https://docs.docker.com/engine/articles/https/ " @@ -181,7 +181,7 @@ class MissingContextParameter(DockerException): def __init__(self, param): self.param = param - def __str__(self): + def __str__(self) -> str: return (f"missing parameter: {self.param}") @@ -189,7 +189,7 @@ class ContextAlreadyExists(DockerException): def __init__(self, name): self.name = name - def __str__(self): + def __str__(self) -> str: return (f"context {self.name} already exists") @@ -197,7 +197,7 @@ class ContextException(DockerException): def __init__(self, msg): self.msg = msg - def __str__(self): + def __str__(self) -> str: return (self.msg) @@ -205,5 +205,5 @@ class ContextNotFound(DockerException): def __init__(self, name): self.name = name - def __str__(self): + def __str__(self) -> str: return (f"context '{self.name}' not found") diff --git a/docker/utils/proxy.py b/docker/utils/proxy.py index e7164b6ce..d0a85637d 100644 --- a/docker/utils/proxy.py +++ b/docker/utils/proxy.py @@ -68,7 +68,7 @@ def inject_proxy_environment(self, environment): # variables defined in "environment" to take precedence. return proxy_env + environment - def __str__(self): + def __str__(self) -> str: return ( 'ProxyConfig(' f'http={self.http}, https={self.https}, ' diff --git a/scripts/versions.py b/scripts/versions.py index 75e5355eb..360d201af 100755 --- a/scripts/versions.py +++ b/scripts/versions.py @@ -51,7 +51,7 @@ def order(self): return (int(self.major), int(self.minor), int(self.patch)) + stage - def __str__(self): + def __str__(self) -> str: stage = f'-{self.stage}' if self.stage else '' edition = f'-{self.edition}' if self.edition else '' return '.'.join(map(str, self[:3])) + edition + stage