Skip to content
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

Add return types to all __str__ methods #3221

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion docker/context/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 6 additions & 6 deletions docker/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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/ "
Expand Down Expand Up @@ -181,29 +181,29 @@ class MissingContextParameter(DockerException):
def __init__(self, param):
self.param = param

def __str__(self):
def __str__(self) -> str:
return (f"missing parameter: {self.param}")


class ContextAlreadyExists(DockerException):
def __init__(self, name):
self.name = name

def __str__(self):
def __str__(self) -> str:
return (f"context {self.name} already exists")


class ContextException(DockerException):
def __init__(self, msg):
self.msg = msg

def __str__(self):
def __str__(self) -> str:
return (self.msg)


class ContextNotFound(DockerException):
def __init__(self, name):
self.name = name

def __str__(self):
def __str__(self) -> str:
return (f"context '{self.name}' not found")
2 changes: 1 addition & 1 deletion docker/utils/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}, '
Expand Down
2 changes: 1 addition & 1 deletion scripts/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading