Skip to content

diagnostic

Diagnostic classes for Clingspector.

Diagnostic dataclass module-attribute

Base class for diagnostics.

This also uses the attribute _registry to call the from_symbol method of the correct diagnostic class.

The attribute _registry is populated by the register_diagnostics decorator at the end of this file.

CyclicDependencyDiagnostic dataclass

Bases: Diagnostic

Diagnostic for cyclic dependencies in variables.

involved_variables instance-attribute

involved_variables: list[str]

List of variables involved in the cycle.

from_symbol staticmethod

from_symbol(symbol: Symbol)

Create a CyclicDependencyDiagnostic from a Clingo symbol.

DiagnosticType

Bases: Enum

Diagnostic types for Clingspector.

TypeMismatchDiagnostic dataclass

Bases: Diagnostic

Diagnostic for type mismatches in variables.

actual_type instance-attribute

actual_type: str

The actual type of the variable.

expected_type instance-attribute

expected_type: str

The expected type of the variable.

variable instance-attribute

variable: str

The variable with a type mismatch.

from_symbol staticmethod

from_symbol(symbol: Symbol)

Create a TypeMismatchDiagnostic from a Clingo symbol.

UndefinedAssignmentDiagnostic dataclass

Bases: Diagnostic

Diagnostic for assigning to undefined variables.

variable instance-attribute

variable: str

The variable that is undefined but still assigned to.

from_symbol staticmethod

from_symbol(symbol: Symbol)

Create an UndefinedAssignmentDiagnostic from a Clingo symbol.

UndefinedDependencyDiagnostic dataclass

Bases: Diagnostic

Diagnostic for variables depending on undefined variables.

undefined_variable instance-attribute

undefined_variable: str

The variable that is not defined.

variable instance-attribute

variable: str

The variable depending on some other, undefined, variable.

from_symbol staticmethod

from_symbol(symbol: Symbol)

Create an UndefinedVariableDiagnostic from a Clingo symbol.

UnsupportedArgumentTypeDiagnostic dataclass

Bases: Diagnostic

Diagnostic for unsupported argument types in operators.

arguments instance-attribute

arguments: list[str]

List of argument types used in the operation.

At least one of these is wrong, but so far we do not know which one.

operator instance-attribute

operator: str

The operator with unsupported argument types.

from_symbol staticmethod

from_symbol(symbol: Symbol)

Create an UnsupportedArgumentTypeDiagnostic from a Clingo symbol.

UnsupportedOperatorDiagnostic dataclass

Bases: Diagnostic

Diagnostic for unsupported operators.

operator instance-attribute

operator: str

The unsupported operator.

from_symbol staticmethod

from_symbol(symbol: Symbol)

Create an UnsupportedOperatorDiagnostic from a Clingo symbol.

UnsupportedTypeDiagnostic dataclass

Bases: Diagnostic

Diagnostic for unsupported types.

type instance-attribute

type: str

The unsupported type.

from_symbol staticmethod

from_symbol(symbol: Symbol)

Create an UnsupportedTypeDiagnostic from a Clingo symbol.

register_diagnostics

register_diagnostics(cls)

Decorator to attach _registry to Diagnostic after subclasses are defined.

The registry is a mapping from DiagnosticType to the corresponding Diagnostic subclass and is used to create instances of diagnostics based on Clingo symbols.