DiagnosticCollector¶
- class DiagnosticCollector(_items: list[Diagnostic] = <factory>)[source]¶
Bases:
objectMutable accumulator for
Diagnosticrecords produced during one stub-generation run.A fresh instance is created inside every
StubContextand passed through the pipeline so every stage can record issues without raising exceptions.- _items¶
Internal ordered list. Use the public properties to access it.
- Type:
list of Diagnostic
Examples
>>> collector = DiagnosticCollector() >>> collector.warning(DiagnosticStage.EMIT, "Foo.bar", "No return annotation") >>> collector.has_warnings() True >>> len(collector) 1
- add(level: DiagnosticLevel, stage: DiagnosticStage, symbol: str, message: str) None[source]¶
Append a diagnostic record.
- Parameters:
level (DiagnosticLevel)
stage (DiagnosticStage)
symbol (str)
message (str)
- info(stage: DiagnosticStage, symbol: str, message: str) None[source]¶
Convenience wrapper — records an
INFOdiagnostic.
- warning(stage: DiagnosticStage, symbol: str, message: str) None[source]¶
Convenience wrapper — records a
WARNINGdiagnostic.
- error(stage: DiagnosticStage, symbol: str, message: str) None[source]¶
Convenience wrapper — records an
ERRORdiagnostic.
- property all: list[Diagnostic]¶
Return a copy of all recorded diagnostics in order.
- property warnings: list[Diagnostic]¶
Return all
WARNINGdiagnostics.
- property errors: list[Diagnostic]¶
Return all
ERRORdiagnostics.
- property infos: list[Diagnostic]¶
Return all
INFOdiagnostics.
- by_stage(stage: DiagnosticStage) list[Diagnostic][source]¶
Return all diagnostics from stage.
- by_symbol(symbol: str) list[Diagnostic][source]¶
Return all diagnostics whose
symbolfield equals symbol.
- summary() str[source]¶
Return a human-readable summary line.
Examples
>>> c = DiagnosticCollector() >>> c.summary() '0 errors, 0 warnings, 0 infos'
- __init__(_items: list[Diagnostic] = <factory>) None¶
See also
Public API reference — overview of all public names.