Checks¶
A check runs the passes over a model, reports each rule at its level and returns a report.
check_model
¶
check_model(
model: Model,
*,
rules: Mapping[str, Level] | None = None,
max_diagnostics: int | None = None,
provenance: Provenance | None = None,
catalog: Catalog | None = None,
settings: Settings | None = None,
) -> Report
Check a model and return a report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
The model to check. |
required |
rules
|
Mapping[str, Level] | None
|
Levels by rule name, or |
None
|
max_diagnostics
|
int | None
|
Maximum number of diagnostics in the report; the error and warning counts cover every diagnostic found. |
None
|
provenance
|
Provenance | None
|
Where the build script placed each element, so the report names
script lines; see :meth: |
None
|
catalog
|
Catalog | None
|
Catalog to resolve parts and colors against;
:func: |
None
|
settings
|
Settings | None
|
Settings to read rule levels and passes' options from; read from the environment and the configuration file by default. |
None
|
Raises:
| Type | Description |
|---|---|
BrickyError
|
If the settings or |
Level
¶
How a check reports a rule's diagnostics, by the names ty gives its levels.
diagnostics
¶
Diagnostics: the facts that passes report, and the reports that collect them.
A rule is one kind of fact a pass checks, such as floating-group. It has a default
level and an exact condition, which bricky explain prints. A diagnostic states one
such fact about the model: what is wrong, the elements involved and their region. A
diagnostic never prescribes a fix: the agent decides what to change.
A check reports each rule at a level: error, warn or ignore. A report gives the level of every rule. It also says what each element a diagnostic names is, and which line of the build script placed it.
Report
¶
The result of a check: a model's diagnostics and what each named element is.
is_error
¶
is_error(diagnostic: Diagnostic) -> bool
Whether the check reported a diagnostic as an error, not as a warning.
Diagnostic
¶
One fact about the model, found by a pass under one rule.
Rule
¶
A fact a pass checks: its name, its default level and the exact condition.
Region
¶
ElementInfo
¶
What an element named by a diagnostic is, and which script line placed it.
registry
¶
The pass plugin protocol, discovery, and the levels that checks report rules at.
A pass is any class with a name, a one-line summary, the rules it checks and
a run method. Packages register passes under the bricky.passes entry-point
group, so a pass pack installs and uninstalls without changes to the core. People
configure rules, never passes: a check runs each pass that checks a rule not ignored.
ENTRY_POINT_GROUP
module-attribute
¶
ENTRY_POINT_GROUP: Final = 'bricky.passes'
The entry-point group that packages register passes under.
BUILT_IN
module-attribute
¶
BUILT_IN: Final = (
"schema",
"collision",
"connectivity",
"stability",
)
The passes of bricky itself, in the order checks run them; others follow, by name.
Pass
¶
installed_passes
cached
¶
Return every installed pass by name, discovered once per process.
The passes of :data:BUILT_IN come first, in that order.
installed_rules
cached
¶
Return every rule an installed pass checks, with the name of that pass.
The rules come in the order of their passes, then as each pass lists them.
Raises:
| Type | Description |
|---|---|
BrickyError
|
If two installed passes claim the same rule, or a pass names a
rule |
resolve_levels
¶
Return the level of every installed rule, ordered as :func:installed_rules.
Each rule starts at its default level. Each layer then applies in turn, such as the
settings and then a command's options: all sets every rule, and a rule's own
entry overrides it. A layer comes with the name that errors give it.
Raises:
| Type | Description |
|---|---|
BrickyError
|
If a layer names a rule that no installed pass checks. |
run_passes
¶
run_passes(
context: Context, levels: Mapping[str, Level]
) -> list[Diagnostic]
Run every pass that checks a rule not ignored, and keep those rules' diagnostics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
Context
|
The model and its shared analyses. |
required |
levels
|
Mapping[str, Level]
|
The level of every installed rule, as :func: |
required |
Raises:
| Type | Description |
|---|---|
BrickyError
|
If a pass reports a rule it does not list. |