pyintents¶
PyIntents package.
- exception pyintents.IntentConfigurationError[source]¶
Bases:
IntentErrorRaised when namespace or decorator configuration is invalid.
- exception pyintents.IntentParseError(func_name, message)[source]¶
Bases:
IntentErrorRaised when function source cannot be parsed or is unavailable.
- exception pyintents.IntentShadowingError(desc)[source]¶
Bases:
IntentErrorRaised when a protected name is shadowed in the local scope.
- Parameters:
desc (str)
- Return type:
None
- class pyintents.Capability(handler, validate)[source]¶
Bases:
objectTrusted synchronous handler and a mandatory resource/argument validator.
The validator must return exactly True to authorize a payload. Validators must be pure: authorization is completed before the handler is invoked.
- class pyintents.IntentDispatcher(capabilities, *, grants, deny=(), max_nodes=10000, max_depth=32, max_bytes=1000000)[source]¶
Bases:
objectA fixed registry with fixed, trusted grants and bounded JSON-like data.
Construct one dispatcher per trusted authorization context. Never derive grants from an unauthenticated request. Registry entries and grants cannot be extended through dispatch(). Resource limits cover data traversal, not handler runtime, memory allocation by the transport, or external effects.
- Parameters:
- exception pyintents.IntentViolationError(func_name, violation, *, path=())[source]¶
Bases:
IntentErrorRaised when a function violates declared capabilities.
- class pyintents.IntentNamespace(uses=None, *, recursive=True, without=None, uselocals=False, usemodule=False, deny=None, allow_unknown=False, deny_dynamic_primitives=True, only_warnings=False, strict=True, max_nodes=10000, analysis_depth=100)[source]¶
Bases:
objectDeclarative capability policy for Python functions.
Security defaults: - recursive=True - allow_unknown=False - deny_dynamic_primitives=True
- usemodule:
Allows functions defined in the same module as the decorated function. Works only with recursive=True.
- Parameters:
- __init__(uses=None, *, recursive=True, without=None, uselocals=False, usemodule=False, deny=None, allow_unknown=False, deny_dynamic_primitives=True, only_warnings=False, strict=True, max_nodes=10000, analysis_depth=100)[source]¶
- intent(uses=None, *, recursive=None, without=None, uselocals=None, usemodule=None, deny=None, allow_unknown=None)[source]¶
- Parameters:
- Return type:
- class pyintents.CallNode(identity, call_name, lineno=None, col_offset=None, resolved_func=None, is_local_definition=False, is_dynamic=False, is_unresolved=False, is_source_available=True, is_cycle=False, children=<factory>)[source]¶
Bases:
objectNode in a call graph.
- Parameters:
- __init__(identity, call_name, lineno=None, col_offset=None, resolved_func=None, is_local_definition=False, is_dynamic=False, is_unresolved=False, is_source_available=True, is_cycle=False, children=<factory>)¶
- class pyintents.CallTree(func, max_depth=1, resolver=None, protected_names=None, *, strict=False, max_nodes=10000, analysis_depth=100)[source]¶
Bases:
objectBuild a call graph for a function.
Root function must have source code available. Child functions without source are represented as opaque nodes.
- Parameters:
- __init__(func, max_depth=1, resolver=None, protected_names=None, *, strict=False, max_nodes=10000, analysis_depth=100)[source]¶
- _build_from_ast(func_def, name, depth, stack, parent_func, local_defs, owner_identity)[source]¶
- Parameters:
func_def (FunctionDef | AsyncFunctionDef)
name (str)
depth (int)
local_defs (dict[str, FunctionDef | AsyncFunctionDef])
owner_identity (str)
- Return type:
- _expand_node(node, func_def, depth, stack, parent_func, local_defs)[source]¶
- Parameters:
node (CallNode)
func_def (FunctionDef | AsyncFunctionDef)
depth (int)
local_defs (dict[str, FunctionDef | AsyncFunctionDef])
- Return type: