| 276 | f.write(footer_str + "\n") |
| 277 | |
| 278 | def _report_any_exprs(self) -> None: |
| 279 | total_any = sum(num_any for num_any, _ in self.counts.values()) |
| 280 | total_expr = sum(total for _, total in self.counts.values()) |
| 281 | total_coverage = 100.0 |
| 282 | if total_expr > 0: |
| 283 | total_coverage = (float(total_expr - total_any) / float(total_expr)) * 100 |
| 284 | |
| 285 | column_names = ["Name", "Anys", "Exprs", "Coverage"] |
| 286 | rows: list[list[str]] = [] |
| 287 | for filename in sorted(self.counts): |
| 288 | num_any, num_total = self.counts[filename] |
| 289 | coverage = (float(num_total - num_any) / float(num_total)) * 100 |
| 290 | coverage_str = f"{coverage:.2f}%" |
| 291 | rows.append([filename, str(num_any), str(num_total), coverage_str]) |
| 292 | rows.sort(key=lambda x: x[0]) |
| 293 | total_row = ["Total", str(total_any), str(total_expr), f"{total_coverage:.2f}%"] |
| 294 | self._write_out_report("any-exprs.txt", column_names, rows, total_row) |
| 295 | |
| 296 | def _report_types_of_anys(self) -> None: |
| 297 | total_counter: collections.Counter[int] = collections.Counter() |