3737from github .Repository import Repository
3838from github .WorkflowJob import WorkflowJob
3939
40- from kernel_patches_daemon .config import EmailConfig , SERIES_TARGET_SEPARATOR
40+ from kernel_patches_daemon .config import (
41+ EmailConfig ,
42+ PRCommentsForwardingConfig ,
43+ SERIES_TARGET_SEPARATOR ,
44+ )
4145from kernel_patches_daemon .github_connector import GithubConnector
4246from kernel_patches_daemon .github_logs import GithubLogExtractor
4347from kernel_patches_daemon .patchwork import Patchwork , Series , Subject
@@ -405,25 +409,27 @@ def reply_email_recipients(
405409
406410
407411async def send_pr_comment_email (
408- config : EmailConfig , msg : EmailMessage , body : str
412+ email_config : EmailConfig , msg : EmailMessage , body : str
409413) -> Optional [str ]:
410414 """
411415 This function forwards a pull request comment (`body`) as an email reply to the original
412416 patch email message `msg`. It extracts recipients from the `msg`, applies allowlist, denylist,
413417 and always_cc as configured, and sets Subject and In-Reply-To based on the `msg`
414418
415419 Args:
416- config : EmailConfig with PRCommentsForwardingConfig
420+ email_config : EmailConfig with PRCommentsForwardingConfig
417421 msg: the original EmailMessage we are replying to (the patch submission)
418422 body: the content of the reply we are sending
419423
420424 Returns:
421425 Message-Id of the sent email, or None if it wasn't sent
422426 """
423- if config is None or not config .is_pr_comment_forwarding_enabled ():
427+ if email_config .pr_comments_forwarding is None :
428+ return
429+ cfg : PRCommentsForwardingConfig = email_config .pr_comments_forwarding
430+ if not cfg .enabled :
424431 return
425432
426- cfg = config .pr_comments_forwarding
427433 (to_list , cc_list ) = reply_email_recipients (
428434 msg , allowlist = cfg .recipient_allowlist , denylist = cfg .recipient_denylist
429435 )
@@ -435,7 +441,7 @@ async def send_pr_comment_email(
435441 subject = "Re: " + msg .get ("Subject" )
436442 in_reply_to = msg .get ("Message-Id" )
437443
438- return await send_email (config , to_list , cc_list , subject , body , in_reply_to )
444+ return await send_email (email_config , to_list , cc_list , subject , body , in_reply_to )
439445
440446
441447def pr_has_label (pr : PullRequest , label : str ) -> bool :
@@ -1293,6 +1299,8 @@ async def evaluate_ci_result(
12931299 logger .info ("No email configuration present; skipping sending..." )
12941300 return
12951301
1302+ email_cfg : EmailConfig = self .email_config
1303+
12961304 if status in (Status .PENDING , Status .SKIPPED ):
12971305 return
12981306
@@ -1329,7 +1337,7 @@ async def evaluate_ci_result(
13291337 subject = await get_ci_email_subject (series )
13301338 ctx = build_email_body_context (self .repo , pr , status , series , inline_logs )
13311339 body = furnish_ci_email_body (ctx )
1332- await send_ci_results_email (self . email_config , series , subject , body )
1340+ await send_ci_results_email (email_cfg , series , subject , body )
13331341 bump_email_status_counters (status )
13341342
13351343 def expire_branches (self ) -> None :
@@ -1379,12 +1387,15 @@ async def submit_pr_summary(
13791387 pr_summary_report .add (1 )
13801388
13811389 async def forward_pr_comments (self , pr : PullRequest , series : Series ):
1382- if (
1383- self .email_config is None
1384- or not self .email_config .is_pr_comment_forwarding_enabled ()
1385- ):
1390+ # The checks and local variables are needed to make type checker happy
1391+ if self .email_config is None :
1392+ return
1393+ email_cfg : EmailConfig = self .email_config
1394+ if email_cfg .pr_comments_forwarding is None :
1395+ return
1396+ cfg : PRCommentsForwardingConfig = email_cfg .pr_comments_forwarding
1397+ if not cfg .enabled :
13861398 return
1387- cfg = self .email_config .pr_comments_forwarding
13881399
13891400 comments = pr .get_issue_comments ()
13901401
@@ -1441,7 +1452,7 @@ async def forward_pr_comments(self, pr: PullRequest, series: Series):
14411452
14421453 # and forward the target comment via email
14431454 sent_msg_id = await send_pr_comment_email (
1444- self . email_config , patch_msg , comment .body
1455+ email_cfg , patch_msg , comment .body
14451456 )
14461457 if sent_msg_id is not None :
14471458 logger .info (
0 commit comments