Skip to content

Commit 34fd1ad

Browse files
committed
clean up : avoid nesting if to generate string representation
1 parent 9c7fd95 commit 34fd1ad

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

mergin/common.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,16 @@ def __init__(self, detail, url=None, server_code=None, server_response=None, htt
2828
self.extra = None
2929

3030
def __str__(self):
31-
return (
32-
f"Detail: {self.detail}\n" + f"HTTP Error: {self.http_error}\n"
33-
if self.http_error
34-
else (
35-
None + f"URL: {self.url}\n"
36-
if self.url
37-
else (
38-
None + f"Method: {self.http_method}\n"
39-
if self.http_method
40-
else None + f"{self.extra}\n" if self.extra else None
41-
)
42-
)
43-
)
31+
string_res = f"Detail: {self.detail}\n"
32+
if self.http_error:
33+
string_res += f"HTTP Error: {self.http_error}\n"
34+
if self.url:
35+
string_res += f"URL: {self.url}\n"
36+
if self.http_method:
37+
string_res += f"Method: {self.http_method}\n"
38+
if self.extra:
39+
string_res += f"{self.extra}\n"
40+
return string_res
4441

4542

4643
class LoginError(Exception):

0 commit comments

Comments
 (0)