Skip to content

check_protocol

checks.check_protocol

Universal protocol class for structural engineering checks. This defines the minimal interface of all checks inside Blueprints.

Classes:

  • CheckProtocol

    Protocol defining the interface for any Blueprint check.

checks.check_protocol.CheckProtocol

Bases: Protocol

Protocol defining the interface for any Blueprint check.

Any class implementing this protocol can be used as a structural check, regardless of inheritance. Provides maximum flexibility for simple checks that don't need to inherit from a common base class.

Notes
  • Use for duck typing and structural subtyping
  • No inheritance required
  • Simple checks can implement this without inheriting from a shared base class
  • Enables both explicit (ABC) and implicit (Protocol) patterns

Examples:

Simple check implementing protocol without inheritance:

>>> @dataclass(frozen=True)
... class MyCheck:
...     name: str
...     source_docs: list[str]
...
...     def result(self) -> CheckResult: ...
...
...     def subchecks(self) -> dict[str, CheckProtocol]: ...
...
...     def calculation_formula(self) -> dict[str, Formula]: ...
...
...     def report(self) -> Report: ...
>>>
>>> check = MyCheck(name="My Check", source_docs=["EN 1992"])
>>> isinstance(check, CheckProtocol)  # True

checks.check_protocol.CheckProtocol.report

report(n: int) -> Report

Generate formatted report of check results.

Produces human-readable reports in various formats for documentation.

Returns:

  • Report

    Formatted report object summarizing check results.

  • n ( int ) –

    Number of decimal places for numerical values in the report.

Source code in blueprints/checks/check_protocol.py
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
def report(self, n: int) -> Report:
    """Generate formatted report of check results.

    Produces human-readable reports in various formats for documentation.

    Returns
    -------
    Report
        Formatted report object summarizing check results.
    n : int
        Number of decimal places for numerical values in the report.
    """
    ...

checks.check_protocol.CheckProtocol.result

result() -> CheckResult

Execute check and return standardized result.

This is the primary public API method. Call this to execute your structural check and get a pass/fail result in a standardized format.

Returns:

  • CheckResult

    Standardized Blueprints result object.

Source code in blueprints/checks/check_protocol.py
84
85
86
87
88
89
90
91
92
93
94
95
def result(self) -> CheckResult:
    """Execute check and return standardized result.

    This is the primary public API method. Call this to execute your
    structural check and get a pass/fail result in a standardized format.

    Returns
    -------
    CheckResult
        Standardized Blueprints result object.
    """
    ...

checks.check_protocol.CheckProtocol.source_docs staticmethod

source_docs() -> list[str]

Return the source documents for this check.

Returns:

  • list[str]

    List of source document identifiers (e.g., standards, codes). For example: ["EN 1993-1-1:2005", "AISC 360-16"]

Source code in blueprints/checks/check_protocol.py
47
48
49
50
51
52
53
54
55
56
57
@staticmethod
def source_docs() -> list[str]:
    """Return the source documents for this check.

    Returns
    -------
    list[str]
        List of source document identifiers (e.g., standards, codes).
        For example: ["EN 1993-1-1:2005", "AISC 360-16"]
    """
    ...

checks.check_protocol.CheckProtocol.subchecks

subchecks() -> dict[str, CheckProtocol]

Get sub-check instances for composite checks.

For example, Check A may comprise sub-checks A1, A2, and A3. In that case, calling subchecks() on Check A would return a dict: {"A1": , "A2": , "A3": }. }

Access this method to get all Check instances that are part of an orchestrated check. Each returned check object has its own result(), calculation_steps(), and report() methods for detailed inspection.

For simple (leaf) checks with no sub-checks, return an empty dict.

Returns:

  • dict[str, CheckProtocol]

    Dictionary mapping descriptive names to Check instances. Empty dict for simple checks with no sub-checks.

Source code in blueprints/checks/check_protocol.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
def subchecks(self) -> dict[str, "CheckProtocol"]:
    """Get sub-check instances for composite checks.

    For example, Check A may comprise sub-checks A1, A2, and A3.
    In that case, calling subchecks() on Check A would return a dict:
    {"A1": <Check A1 instance>,
     "A2": <Check A2 instance>,
     "A3": <Check A3 instance>}.
    }

    Access this method to get all Check instances that are part of an
    orchestrated check. Each returned check object has its own result(),
    calculation_steps(), and report() methods for detailed inspection.

    For simple (leaf) checks with no sub-checks, return an empty dict.

    Returns
    -------
    dict[str, CheckProtocol]
        Dictionary mapping descriptive names to Check instances.
        Empty dict for simple checks with no sub-checks.

    """
    ...