Print collected diagnostics to stderr, advance ``fired_count`` by the number flushed, and clear the pending list.
(self)
| 52 | self.pending.append(Diagnostic(message=message, source=source)) |
| 53 | |
| 54 | def flush(self) -> None: |
| 55 | """Print collected diagnostics to stderr, advance ``fired_count`` |
| 56 | by the number flushed, and clear the pending list.""" |
| 57 | if not self.pending: |
| 58 | return |
| 59 | print(f"\n--- codegen diagnostics ({len(self.pending)}) ---", |
| 60 | file=sys.stderr) |
| 61 | for d in self.pending: |
| 62 | print(d.message, file=sys.stderr) |
| 63 | print( |
| 64 | "(diagnostics are non-fatal; the codegen has emitted what it " |
| 65 | "can — fix the rules to silence them.)", |
| 66 | file=sys.stderr, |
| 67 | ) |
| 68 | self.fired_count += len(self.pending) |
| 69 | self.pending.clear() |
| 70 | |
| 71 | def reset(self) -> None: |
| 72 | self.pending.clear() |