7070 re .VERBOSE ,
7171)
7272
73- CONFORMANCE_URL = "https://github.com/python/typing/blob/{conformance_suite_commit}/conformance/tests/{filename}#L{line}"
7473CONFORMANCE_SUITE_COMMIT = os .environ .get ("CONFORMANCE_SUITE_COMMIT" , "main" )
74+ CONFORMANCE_DIR_WITH_README = (
75+ f"https://github.com/python/typing/blob/{ CONFORMANCE_SUITE_COMMIT } /conformance/"
76+ )
77+ CONFORMANCE_URL = CONFORMANCE_DIR_WITH_README + "/tests/{filename}#L{line}"
7578
7679
7780class Source (Flag ):
@@ -89,13 +92,13 @@ class Classification(StrEnum):
8992 def into_title (self ) -> str :
9093 match self :
9194 case Classification .TRUE_POSITIVE :
92- return "True positives added 🎉 "
95+ return "True positives added"
9396 case Classification .FALSE_POSITIVE :
94- return "False positives added 🫤 "
97+ return "False positives added"
9598 case Classification .TRUE_NEGATIVE :
96- return "False positives removed 🎉 "
99+ return "False positives removed"
97100 case Classification .FALSE_NEGATIVE :
98- return "True positives removed 🫤 "
101+ return "True positives removed"
99102
100103
101104@dataclass (kw_only = True , slots = True )
@@ -415,7 +418,7 @@ def render_grouped_diagnostics(
415418 ):
416419 group = list (group )
417420
418- lines .append (f"## { classification .into_title ()} " )
421+ lines .append (f"### { classification .into_title ()} " )
419422 lines .extend (["" , "<details>" , "" ])
420423
421424 lines .extend (header )
@@ -478,6 +481,8 @@ def format_metric(diff: float, old: float, new: float):
478481 false_neg_change = new .false_negatives - old .false_negatives
479482 total_change = new .total - old .total
480483
484+ base_header = f"[Typing conformance results]({ CONFORMANCE_DIR_WITH_README } )"
485+
481486 if (
482487 precision_change == 0
483488 and recall_change == 0
@@ -486,7 +491,13 @@ def format_metric(diff: float, old: float, new: float):
486491 and false_neg_change == 0
487492 and total_change == 0
488493 ):
489- return "## Typing conformance\n \n No changes"
494+ return dedent (
495+ f"""
496+ ## { base_header }
497+
498+ No changes detected ✅
499+ """
500+ )
490501
491502 true_pos_diff = diff_format (true_pos_change , greater_is_better = True )
492503 false_pos_diff = diff_format (false_pos_change , greater_is_better = False )
@@ -495,9 +506,29 @@ def format_metric(diff: float, old: float, new: float):
495506 recall_diff = diff_format (recall_change , greater_is_better = True )
496507 total_diff = diff_format (total_change , neutral = True )
497508
498- table = dedent (
509+ if (precision_change > 0 and recall_change >= 0 ) or (
510+ recall_change > 0 and precision_change >= 0
511+ ):
512+ header = f"{ base_header } improved 🎉"
513+ elif (precision_change < 0 and recall_change <= 0 ) or (
514+ recall_change < 0 and precision_change <= 0
515+ ):
516+ header = f"{ base_header } regressed ❌"
517+ else :
518+ header = base_header
519+
520+ summary_paragraph = (
521+ f"The percentage of diagnostics emitted that were expected errors "
522+ f"{ format_metric (precision_change , old .precision , new .precision )} . "
523+ f"The percentage of expected errors that received a diagnostic "
524+ f"{ format_metric (recall_change , old .recall , new .recall )} ."
525+ )
526+
527+ return dedent (
499528 f"""
500- ## Typing Conformance
529+ ## { header }
530+
531+ { summary_paragraph }
501532
502533 ### Summary
503534
@@ -513,15 +544,6 @@ def format_metric(diff: float, old: float, new: float):
513544 """
514545 )
515546
516- summary = (
517- f"The percentage of diagnostics emitted that were expected errors"
518- f" { format_metric (precision_change , old .precision , new .precision )} ,"
519- " and the percentage of expected errors that received a diagnostic"
520- f" { format_metric (recall_change , old .recall , new .recall )} ."
521- )
522-
523- return "\n " .join ([table , summary ])
524-
525547
526548def parse_args ():
527549 parser = argparse .ArgumentParser (
0 commit comments