arxpy.diagnostics

arxpy.diagnostics

Source: packages/arxpy/src/arxpy/diagnostics.py

title: Structured diagnostic records for the ArxPy public API.
summary: >-
  Define the stable, frozen Diagnostic record and the DiagnosticSeverity enum
  that ArxPy exposes to callers, plus the duck-typed helpers that translate
  upstream irx structured diagnostics and arx parser exceptions into it. The
  Diagnostic type strips the astx.AST node reference that irx records carry, so
  external callers never see raw compiler internals. These modules never import
  arx or irx at module load time, so importing arxpy.diagnostics stays free of
  the LLVM toolchain.

Functions

coerce_severity(value: object) -> DiagnosticSeverity

title: Coerce an upstream severity value into a DiagnosticSeverity.
summary: >-
  Current irx diagnostics expose severity as a plain string such as
  "error"; enum-like values exposing `.value` are also handled.
  Unrecognised values fall back to ERROR.
parameters:
  value:
    type: object
returns:
  type: DiagnosticSeverity

resolve_source(record: object) -> object | None

title: Return the best-effort source location of an irx diagnostic.
parameters:
  record:
    type: object
returns:
  type: object | None

resolve_module_key(record: object) -> str | None

title: Return the best-effort module attribution of an irx diagnostic.
parameters:
  record:
    type: object
returns:
  type: str | None

from_irx(record: object, *, filename: str | None=None) -> Diagnostic

title: Translate one irx structured diagnostic into an ArxPy Diagnostic.
summary: >-
  Reads the upstream record by attribute so it accepts any irx.diagnostics
  Diagnostic without importing irx, and discards the astx.AST node
  reference. The current irx SourceLocation carries no filename, so the
  attribution falls back to an explicit filename, then the diagnostic's
  module key, then "<unknown>".
parameters:
  record:
    type: object
  filename:
    type: str | None
returns:
  type: Diagnostic

from_arx_error(exc: object, *, filename: str='<string>') -> Diagnostic

title: Translate an expected Arx frontend error into a Diagnostic.
summary: >-
  Reads the stable code and optional source location exposed by ArxError
  without importing the frontend at module import time.
parameters:
  exc:
    type: object
  filename:
    type: str
returns:
  type: Diagnostic

from_parser_exception(exc: object, *, filename: str='<string>') -> Diagnostic

title: Translate an Arx parser failure into an ArxPy Diagnostic.
summary: Compatibility alias for the general expected-frontend adapter.
parameters:
  exc:
    type: object
  filename:
    type: str
returns:
  type: Diagnostic

Classes

DiagnosticSeverity(Enum)

title: Severity level of a diagnostic.

Diagnostic

title: One structured diagnostic exposed by the ArxPy API.
attributes:
  severity:
    type: DiagnosticSeverity
    description: The severity level of the diagnostic.
  message:
    type: str
    description: The human-readable diagnostic message.
  filename:
    type: str
    description: Source attribution, or "<string>" / "<unknown>".
  line:
    type: int | None
    description: One-based source line, when known.
  column:
    type: int | None
    description: One-based source column, when known.
  code:
    type: str | None
    description: Stable diagnostic code, e.g. "S001", when known.
Back to top