Skip to content

Commit

Permalink
chore: fix ruff lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
link2xt committed Sep 6, 2023
1 parent 74b0380 commit 9f3b426
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/mailadm/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def main(mailadm_db, admbot_db_path):
while 1:
for logmsg in prune(mailadm_db).get("message"):
logging.info("%s", logmsg)
for _second in range(0, 600):
for _second in range(600):
if not ac._event_thread.is_alive():
logging.error("dc core event thread died, exiting now")
os._exit(1)
Expand Down
8 changes: 4 additions & 4 deletions src/mailadm/mailcow.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def add_user_mailcow(self, addr, password, token, quota=0):
"tags": ["mailadm:" + token],
}
result = r.post(url, json=payload, headers=self.auth, timeout=HTTP_TIMEOUT)
if type(result.json()) != list or result.json()[0].get("type") != "success":
if not isinstance(result.json(), list) or result.json()[0].get("type") != "success":
raise MailcowError(result.json())

def del_user_mailcow(self, addr):
Expand All @@ -59,12 +59,12 @@ def get_user(self, addr):
json = result.json()
if json == {}:
return None
if type(json) == dict:
if isinstance(json, dict):
if json.get("type") == "error":
raise MailcowError(json)
return MailcowUser(json)
# some mailcow versions return all users, even if you only ask for a specific one:
if type(json) == list:
if isinstance(json, list):
for user in [MailcowUser(user) for user in json]:
if user.addr == addr:
return user
Expand All @@ -79,7 +79,7 @@ def get_user_list(self):
json = result.json()
if json == {}:
return []
if type(json) == dict:
if isinstance(json, dict):
if json.get("type") == "error":
raise MailcowError(json)
return [MailcowUser(user) for user in json]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def add_user_db(*args, **kwargs):
auth = {"X-API-Key": conn.config.mailcow_token}
result = requests.get(url, headers=auth)
assert result.status_code == 200
if result.json() is not {} and type(result.json()) == list:
if result.json() is not {} and not isinstance(result.json(), list):
for user in result.json():
assert user["username"] != addr

Expand Down Expand Up @@ -243,4 +243,4 @@ def test_delete_user_mailcow_missing(conn, mailcow, mailcow_domain):

def test_db_version(conn):
version = conn.get_dbversion()
assert type(version) == int
assert isinstance(version, int)

0 comments on commit 9f3b426

Please sign in to comment.