Skip to content

Commit 27d90fb

Browse files
committed
dependencies: Update dependencies due conflict resolution and linting
Some of dependencies changes require minimal API changes. Also more missed linting fixes. Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
1 parent d038a89 commit 27d90fb

27 files changed

Lines changed: 788 additions & 329 deletions

api/admin.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ async def setup_admin_user(db, username, email, password=None):
2929
if not password:
3030
password = os.getenv("KCI_INITIAL_PASSWORD")
3131
if not password:
32-
print("Password is empty and KCI_INITIAL_PASSWORD is not set, aborting.")
32+
print(
33+
"Password is empty and KCI_INITIAL_PASSWORD is not set, aborting."
34+
)
3335
return None
3436
else:
35-
retyped = getpass.getpass(f"Retype password for user '{username}': ")
37+
retyped = getpass.getpass(
38+
f"Retype password for user '{username}': "
39+
)
3640
if password != retyped:
3741
print("Sorry, passwords do not match, aborting.")
3842
return None
@@ -67,7 +71,9 @@ async def main(args):
6771
db = Database(args.mongo, args.database)
6872
await db.initialize_beanie()
6973
await db.create_indexes()
70-
created = await setup_admin_user(db, args.username, args.email, password=args.password)
74+
created = await setup_admin_user(
75+
db, args.username, args.email, password=args.password
76+
)
7177
return created is not None
7278

7379

@@ -79,8 +85,12 @@ async def main(args):
7985
help="Mongo server connection string",
8086
)
8187
parser.add_argument("--username", default="admin", help="Admin username")
82-
parser.add_argument("--database", default="kernelci", help="KernelCI database name")
83-
parser.add_argument("--email", required=True, help="Admin user email address")
88+
parser.add_argument(
89+
"--database", default="kernelci", help="KernelCI database name"
90+
)
91+
parser.add_argument(
92+
"--email", required=True, help="Admin user email address"
93+
)
8494
parser.add_argument(
8595
"--password",
8696
default="",

api/db.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ def _translate_operators(self, attributes):
151151
if isinstance(op_value, str) and op_value.isdecimal():
152152
op_value = int(op_value)
153153
if translated_attributes.get(key):
154-
translated_attributes[key].update({op_key: op_value})
154+
translated_attributes[key].update(
155+
{op_key: op_value}
156+
)
155157
else:
156158
translated_attributes[key] = {op_key: op_value}
157159
return translated_attributes
@@ -251,15 +253,19 @@ async def insert_many(self, model, documents):
251253
result = await col.insert_many(documents)
252254
return result.inserted_ids
253255

254-
async def _create_recursively(self, hierarchy: Hierarchy, parent: Node, cls, col):
256+
async def _create_recursively(
257+
self, hierarchy: Hierarchy, parent: Node, cls, col
258+
):
255259
obj = parse_node_obj(hierarchy.node)
256260
if parent:
257261
obj.parent = parent.id
258262
if obj.id:
259263
obj.update()
260264
if obj.parent == obj.id:
261265
raise ValueError("Parent cannot be the same as the object")
262-
res = await col.replace_one({"_id": ObjectId(obj.id)}, obj.dict(by_alias=True))
266+
res = await col.replace_one(
267+
{"_id": ObjectId(obj.id)}, obj.dict(by_alias=True)
268+
)
263269
if res.matched_count == 0:
264270
raise ValueError(f"No object found with id: {obj.id}")
265271
else:
@@ -293,7 +299,9 @@ async def update(self, obj):
293299
obj.update()
294300
if obj.parent == obj.id:
295301
raise ValueError("Parent cannot be the same as the object")
296-
res = await col.replace_one({"_id": ObjectId(obj.id)}, obj.dict(by_alias=True))
302+
res = await col.replace_one(
303+
{"_id": ObjectId(obj.id)}, obj.dict(by_alias=True)
304+
)
297305
if res.matched_count == 0:
298306
raise ValueError(f"No object found with id: {obj.id}")
299307
return obj.__class__(**await col.find_one(ObjectId(obj.id)))

api/email_sender.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ def __init__(self):
2626
def _smtp_connect(self):
2727
"""Method to create a connection with SMTP server"""
2828
if self._settings.smtp_port == 465:
29-
smtp = smtplib.SMTP_SSL(self._settings.smtp_host, self._settings.smtp_port)
29+
smtp = smtplib.SMTP_SSL(
30+
self._settings.smtp_host, self._settings.smtp_port
31+
)
3032
else:
31-
smtp = smtplib.SMTP(self._settings.smtp_host, self._settings.smtp_port)
33+
smtp = smtplib.SMTP(
34+
self._settings.smtp_host, self._settings.smtp_port
35+
)
3236
smtp.starttls()
3337
smtp.login(self._settings.email_sender, self._settings.email_password)
3438
return smtp
@@ -60,7 +64,11 @@ def _send_email(self, email_msg):
6064
detail="Failed to send email",
6165
) from exc
6266

63-
def create_and_send_email(self, email_subject, email_content, email_recipient):
67+
def create_and_send_email(
68+
self, email_subject, email_content, email_recipient
69+
):
6470
"""Method to create and send email"""
65-
email_msg = self._create_email(email_subject, email_content, email_recipient)
71+
email_msg = self._create_email(
72+
email_subject, email_content, email_recipient
73+
)
6674
self._send_email(email_msg)

0 commit comments

Comments
 (0)