Skip to content

Commit 13c68ed

Browse files
committed
Fix a typecheck error and reformat with black
Signed-off-by: Ihor Solodrai <[email protected]>
1 parent 4b2ecd4 commit 13c68ed

File tree

6 files changed

+29
-30
lines changed

6 files changed

+29
-30
lines changed

kernel_patches_daemon/__main__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
)
2828
from opentelemetry.sdk.resources import Resource
2929

30-
3130
logger: logging.Logger = logging.getLogger(__name__)
3231

3332

kernel_patches_daemon/branch_worker.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
from opentelemetry import metrics
7272
from pyre_extensions import none_throws
7373

74-
7574
logger: logging.Logger = logging.getLogger(__name__)
7675
meter: metrics.Meter = metrics.get_meter("branch_worker")
7776

@@ -383,7 +382,7 @@ async def send_ci_results_email(
383382
subject: str,
384383
body: str,
385384
):
386-
(to_list, cc_list) = ci_results_email_recipients(config, series)
385+
to_list, cc_list = ci_results_email_recipients(config, series)
387386
in_reply_to = get_ci_base(series)["msgid"]
388387
await send_email(config, to_list, cc_list, subject, body, in_reply_to)
389388

@@ -413,7 +412,7 @@ def reply_email_recipients(
413412

414413
sender = msg.get("From")
415414
if sender is not None:
416-
(_, sender_address) = email.utils.parseaddr(sender)
415+
_, sender_address = email.utils.parseaddr(sender)
417416
if sender_address: # parseaddr might return an emptystring
418417
to_list.append(sender_address)
419418

@@ -459,7 +458,7 @@ async def send_pr_comment_email(
459458
if not cfg.enabled:
460459
return
461460

462-
(to_list, cc_list) = reply_email_recipients(
461+
to_list, cc_list = reply_email_recipients(
463462
msg,
464463
allowlist=cfg.recipient_allowlist,
465464
denylist=cfg.recipient_denylist,
@@ -1417,7 +1416,11 @@ def expire_branches(self) -> None:
14171416
# that doesn't have any closed PRs
14181417
# with last update within defined TTL
14191418
pr = self.filter_closed_pr(branch)
1420-
if not pr or time.time() - pr.updated_at.timestamp() > BRANCH_TTL:
1419+
if (
1420+
not pr
1421+
or not pr.updated_at
1422+
or time.time() - pr.updated_at.timestamp() > BRANCH_TTL
1423+
):
14211424
self.delete_branch(branch)
14221425

14231426
def expire_user_prs(self) -> None:

kernel_patches_daemon/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from dataclasses import dataclass
1414
from typing import Dict, List, Optional
1515

16-
1716
logger = logging.getLogger(__name__)
1817

1918
SERIES_TARGET_SEPARATOR = "=>"

kernel_patches_daemon/github_connector.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
TOKEN_REFRESH_THRESHOLD_TIMEDELTA = timedelta(
3838
seconds=ACCESS_TOKEN_REFRESH_THRESHOLD_SECONDS
3939
)
40-
assert hasattr(Auth, "TOKEN_REFRESH_THRESHOLD_TIMEDELTA"), (
41-
"Could not monkey patch TOKEN_REFRESH_THRESHOLD_TIMEDELTA, it may have changed upstream."
42-
)
40+
assert hasattr(
41+
Auth, "TOKEN_REFRESH_THRESHOLD_TIMEDELTA"
42+
), "Could not monkey patch TOKEN_REFRESH_THRESHOLD_TIMEDELTA, it may have changed upstream."
4343
Auth.TOKEN_REFRESH_THRESHOLD_TIMEDELTA = TOKEN_REFRESH_THRESHOLD_TIMEDELTA
4444

4545
BOT_USER_LOGIN_SUFFIX = "[bot]"
@@ -65,9 +65,9 @@ def __init__(
6565
app_auth: Optional[Auth.AppInstallationAuth] = None,
6666
http_retries: Optional[int] = None,
6767
) -> None:
68-
assert bool(github_oauth_token) ^ bool(app_auth), (
69-
"Only one of github_oauth_token or app_auth can be set"
70-
)
68+
assert bool(github_oauth_token) ^ bool(
69+
app_auth
70+
), "Only one of github_oauth_token or app_auth can be set"
7171
self.repo_name: str = os.path.basename(repo_url)
7272
self.base_repo_url: str = repo_url
7373
self.auth_type = AuthType.UNKNOWN
@@ -135,9 +135,9 @@ def __init__(
135135
self.user_or_org = org
136136
self.repo = self.git.get_organization(org).get_repo(self.repo_name)
137137

138-
assert self.auth_type != AuthType.UNKNOWN, (
139-
"Auth type is still set to unknown... something is wrong."
140-
)
138+
assert (
139+
self.auth_type != AuthType.UNKNOWN
140+
), "Auth type is still set to unknown... something is wrong."
141141

142142
def __get_new_auth_token(self) -> str:
143143
# refresh token if needed

kernel_patches_daemon/github_sync.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
from opentelemetry import metrics
3434
from pyre_extensions import none_throws
3535

36-
3736
logger: logging.Logger = logging.getLogger(__name__)
3837
meter: metrics.Meter = metrics.get_meter("github_sync")
3938

@@ -248,7 +247,7 @@ async def sync_relevant_subject(self, subject: Subject) -> None:
248247
worker = self.workers[branch]
249248
# PR branch name == sid of the first known series
250249
pr_branch_name = await worker.subject_to_branch(subject)
251-
(applied, _, _) = await worker.try_apply_mailbox_series(
250+
applied, _, _ = await worker.try_apply_mailbox_series(
252251
pr_branch_name, series
253252
)
254253
if not applied:

tests/test_branch_worker.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
)
6565
from tests.common.utils import load_test_data, read_fixture, read_test_data_file
6666

67-
6867
TEST_REPO = "repo"
6968
TEST_REPO_URL = f"https://user:[email protected]/org/{TEST_REPO}"
7069
TEST_REPO_BRANCH = "test_branch"
@@ -1337,7 +1336,7 @@ def test_email_submitter_in_allowlist(self):
13371336
]
13381337
expected_email = read_fixture("test_email_submitter_in_allowlist.golden")
13391338

1340-
(to_list, cc_list) = ci_results_email_recipients(config, series)
1339+
to_list, cc_list = ci_results_email_recipients(config, series)
13411340
in_reply_to = get_ci_base(series)["msgid"]
13421341
cmd, email = build_email(
13431342
config,
@@ -1397,7 +1396,7 @@ def test_email_submitter_not_in_allowlist(self):
13971396
]
13981397
expected_email = read_fixture("test_email_submitter_not_in_allowlist.golden")
13991398

1400-
(to_list, cc_list) = ci_results_email_recipients(config, series)
1399+
to_list, cc_list = ci_results_email_recipients(config, series)
14011400
in_reply_to = get_ci_base(series)["msgid"]
14021401
cmd, email = build_email(
14031402
config,
@@ -1461,7 +1460,7 @@ def test_email_submitter_not_in_allowlist_and_allowlist_disabled(self):
14611460
"test_email_submitter_not_in_allowlist_and_allowlist_disabled.golden"
14621461
)
14631462

1464-
(to_list, cc_list) = ci_results_email_recipients(config, series)
1463+
to_list, cc_list = ci_results_email_recipients(config, series)
14651464
in_reply_to = get_ci_base(series)["msgid"]
14661465
cmd, email = build_email(
14671466
config,
@@ -1484,21 +1483,21 @@ def test_reply_email_recipients(self):
14841483
msg = parser.parsebytes(mbox.encode("utf-8"), headersonly=True)
14851484
self.assertIsNotNone(mbox)
14861485
denylist = [re.compile(".*@vger.kernel.org")]
1487-
(to_list, cc_list) = reply_email_recipients(msg, denylist=denylist)
1486+
to_list, cc_list = reply_email_recipients(msg, denylist=denylist)
14881487

14891488
self.assertIn("[email protected]", to_list)
14901489
self.assertEqual(len(to_list), 17)
14911490
self.assertEqual(len(cc_list), 1)
14921491

14931492
allowlist = [re.compile(".*@vger.kernel.org")]
1494-
(to_list, cc_list) = reply_email_recipients(msg, allowlist=allowlist)
1493+
to_list, cc_list = reply_email_recipients(msg, allowlist=allowlist)
14951494
self.assertEqual(to_list, [])
14961495
self.assertEqual(len(cc_list), 3)
14971496

14981497
# test both
14991498
allowlist = [re.compile(".*@linux.dev")]
15001499
denylist = [re.compile(".*@gmail.com")]
1501-
(to_list, cc_list) = reply_email_recipients(
1500+
to_list, cc_list = reply_email_recipients(
15021501
msg, allowlist=allowlist, denylist=denylist
15031502
)
15041503
self.assertIn("[email protected]", to_list)
@@ -1507,13 +1506,13 @@ def test_reply_email_recipients(self):
15071506

15081507
# test denylist all
15091508
denylist = [re.compile(".*")]
1510-
(to_list, cc_list) = reply_email_recipients(msg, denylist=denylist)
1509+
to_list, cc_list = reply_email_recipients(msg, denylist=denylist)
15111510
self.assertEqual(to_list, [])
15121511
self.assertEqual(cc_list, [])
15131512

15141513
# test denylist all, but the sender
15151514
denylist = [re.compile(".*")]
1516-
(to_list, cc_list) = reply_email_recipients(
1515+
to_list, cc_list = reply_email_recipients(
15171516
msg, denylist=denylist, always_reply_to_author=True
15181517
)
15191518
self.assertEqual(to_list, ["[email protected]"])
@@ -1707,9 +1706,9 @@ async def test_forward_pr_comments(self, m: aioresponses) -> None:
17071706
)
17081707

17091708
mock_send_email.assert_called_once()
1710-
(_, to_list, cc_list, subject, body, in_reply_to) = (
1711-
mock_send_email.call_args[0]
1712-
)
1709+
_, to_list, cc_list, subject, body, in_reply_to = mock_send_email.call_args[
1710+
0
1711+
]
17131712

17141713
self.assertIn("[email protected]", to_list)
17151714
self.assertEqual(len(to_list), 17)

0 commit comments

Comments
 (0)