Source code for syside.evaluation

 1"""
 2``syside.evaluation``: evaluate asserted constraints at the usages of a model.
 3
 4This package checks whether the ``assert constraint { ... }`` constraints in a
 5model actually hold for the usages that should satisfy them. It is built on
 6:meth:`syside.Compiler.evaluate`, which defines exactly which constraints
 7can be checked; a constraint it cannot evaluate is reported
 8:attr:`Verdict.UNDECIDABLE` rather than silently passed.
 9
10The public surface is small:
11
12* :func:`check_model`: check every constraint against every usage in the
13  user model (a usage in whose scope some value the constraint reads has no
14  ``=`` binding, declared or inherited, is reported ``UNDECIDABLE``, not
15  skipped).
16* :func:`check_usage`: check the constraints applying to one usage.
17* :func:`evaluate_assertion`: evaluate one assertion in an explicit scope.
18* :class:`ConstraintResult` / :class:`Verdict`: the result type (``HOLDS``,
19  ``VIOLATED``, ``UNDECIDABLE``, or ``UNSUPPORTED``).
20"""
21
22from __future__ import annotations
23
24from syside.evaluation._constraints import (
25    ConstraintResult,
26    UnsupportedUsageError,
27    Verdict,
28    check_usage,
29    check_model,
30    evaluate_assertion,
31)
32
33__all__ = [
34    "Verdict",
35    "ConstraintResult",
36    "UnsupportedUsageError",
37    "evaluate_assertion",
38    "check_usage",
39    "check_model",
40]