Precheck
precheck
Pure in-memory static checks over a parsed batch_edit operation set.
Every function here is side-effect free and never touches the filesystem:
file contents are supplied by the caller as file -> lines mappings. The
operation schemas are imported from :mod:axm_edit.models.operations — this
module declares no parallel schema of its own.
StaticOperation = ReplaceOp | CreateOp | DeleteOp | RewriteOp
module-attribute
Any already-parsed batch operation accepted by the static checks.
anchor_excerpt(old)
Render an anchor as a bounded, single-line excerpt for a diagnostic.
Invisible characters are named by
:func:~axm_edit.core.diagnostics.render_invisibles — a line feed becomes
<LF>, so the excerpt never carries a raw newline — and the result is
clamped by the single truncation rule of that same module, ellipsis
marker included.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old
|
str
|
The anchor text to echo back to the caller. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The rendered anchor, at most |
Source code in packages/axm-edit/src/axm_edit/core/precheck.py
check_anchor_quotes(op_index, file, old, edit_index=None)
Report an anchor containing a triple-quote delimiter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
op_index
|
int
|
0-indexed position of the operation in the batch. |
required |
file
|
str
|
Relative path targeted by the operation. |
required |
old
|
str
|
The anchor text to inspect. |
required |
edit_index
|
int | None
|
0-indexed position of the edit inside that operation,
echoed back on the diagnostic; |
None
|
Returns:
| Type | Description |
|---|---|
list[CheckDiagnostic]
|
A single |
Source code in packages/axm-edit/src/axm_edit/core/precheck.py
check_anchor_whole_line(op_index, file, lines, old, edit_index=None)
Report a multi-line anchor that does not span whole lines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
op_index
|
int
|
0-indexed position of the operation in the batch. |
required |
file
|
str
|
Relative path targeted by the operation. |
required |
lines
|
Sequence[str]
|
In-memory content of |
required |
old
|
str
|
The anchor text to inspect. |
required |
edit_index
|
int | None
|
0-indexed position of the edit inside that operation,
echoed back on the diagnostic; |
None
|
Returns:
| Type | Description |
|---|---|
list[CheckDiagnostic]
|
A single |
list[CheckDiagnostic]
|
single-line anchor never yields this code. |
Source code in packages/axm-edit/src/axm_edit/core/precheck.py
check_edit_keys(op_index, file, raw_edit)
Report keys of raw_edit that are not part of the Edit schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
op_index
|
int
|
0-indexed position of the operation in the batch. |
required |
file
|
str
|
Relative path targeted by the operation. |
required |
raw_edit
|
Mapping[str, object]
|
Mapping as authored, before validation. |
required |
Returns:
| Type | Description |
|---|---|
list[CheckDiagnostic]
|
A single |
list[CheckDiagnostic]
|
belongs to :class: |
Source code in packages/axm-edit/src/axm_edit/core/precheck.py
check_rewrite_keys(op_index, file, raw_op)
Report the payload-shape faults of a raw rewrite operation.
Pure by construction: the mapping is inspected exactly as authored, no
path is resolved and no file is read. The on-disk verdict belongs to
:func:~axm_edit.core.precheck_fs.check_rewrite_targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
op_index
|
int
|
0-indexed position of the operation in the batch. |
required |
file
|
str
|
Relative path targeted by the operation. |
required |
raw_op
|
Mapping[str, object]
|
Rewrite mapping as authored, before validation. |
required |
Returns:
| Type | Description |
|---|---|
list[CheckDiagnostic]
|
A |
list[CheckDiagnostic]
|
a |
list[CheckDiagnostic]
|
|
list[CheckDiagnostic]
|
|
Source code in packages/axm-edit/src/axm_edit/core/precheck.py
run_static_checks(operations, contents)
Aggregate every static check over an already-parsed operation set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operations
|
Sequence[StaticOperation]
|
Parsed operations, in batch order. |
required |
contents
|
Mapping[str, Sequence[str]]
|
In-memory |
required |
Returns:
| Type | Description |
|---|---|
list[CheckDiagnostic]
|
Every diagnostic found, sorted by increasing |