arxjit.validation
arxjit.validation
Source: packages/arxjit/src/arxjit/validation.py
title: Python-subset validation for arxjit.
summary: >-
Second stage of the arxjit pipeline: walk the ast node produced by
arxjit.source and check it only uses the v1 supported subset of pure Python
(typed scalar arguments, arithmetic/comparison/boolean expressions, single-
target local assignments, if/else, while, for over range, return). Dispatch
is by node type via plum, matching the visitor convention used across the Arx
packages. Every rejected construct is collected into its own Diagnostic so a
function using several unsupported constructs reports all of them at once via
UnsupportedSyntaxError; lowering the accepted subset to astx is a later stage
and is not done here.Functions
validate(extracted: ExtractedSource) -> None
title: Validate that a function uses only the supported Python subset.
summary: >-
Rejects functions defined in a class body, async definitions and generic
(PEP 695) type parameters, checks the argument shape, then walks the body
collecting one diagnostic per rejected construct, including free-variable
reads (closures and globals). A function with several unsupported
constructs is reported in a single UnsupportedSyntaxError carrying all of
them, so a user fixes everything in one pass. See _defined_in_class_body
for the method forms this cannot detect from source metadata alone.
parameters:
extracted:
type: ExtractedSource
description: The result of arxjit.source.extract_source.
raises:
UnsupportedSyntaxError: >-
If the function is defined in a class body, is async or generic, has an
unsupported argument shape, reads a free variable, or its body uses any
construct outside the v1 subset.