Skip to content

Commit 4cbb3f5

Browse files
committed
simplify ifs
1 parent e876fd1 commit 4cbb3f5

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

mergin/client.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,16 @@ def __init__(
146146
self.opener = urllib.request.build_opener(*handlers, https_handler)
147147
urllib.request.install_opener(self.opener)
148148

149-
if login or password:
150-
if login and not password:
151-
raise ClientError("Unable to log in: no password provided for '{}'".format(login))
152-
if password and not login:
153-
raise ClientError("Unable to log in: password provided but no username/email")
154-
155-
if login and password:
156-
self._auth_params = {"login": login, "password": password}
157-
if not self._auth_session:
158-
self.login(login, password)
159-
160-
else:
149+
if login and not password:
150+
raise ClientError("Unable to log in: no password provided for '{}'".format(login))
151+
if password and not login:
152+
raise ClientError("Unable to log in: password provided but no username/email")
153+
if not any(login, password, self._auth_session):
154+
raise ClientError("Unable to log in: no auth token provided for login")
155+
if login and password:
156+
self._auth_params = {"login": login, "password": password}
161157
if not self._auth_session:
162-
raise ClientError("Unable to log in: no auth token provided for login")
158+
self.login(login, password)
163159

164160
def setup_logging(self):
165161
"""Setup Mergin Maps client logging."""

0 commit comments

Comments
 (0)