builtins
This module contains the class which defines the builtin values for the engine.
- class Builtins(values: Mapping[str, Any], namespace: str | None = None, timezone: tzinfo | None = None, value_types: Mapping[str, _DataTypeDef] | None = None)[source]
Bases:
MappingA class to define and provide variables to within the builtin context of rules. These can be accessed by specifying a symbol name with the
$prefix.- __init__(values: Mapping[str, Any], namespace: str | None = None, timezone: tzinfo | None = None, value_types: Mapping[str, _DataTypeDef] | None = None) None[source]
- Parameters:
values (dict) – A mapping of string keys to be used as symbol names with values of either Python literals or a function which will be called when the symbol is accessed. When using a function, it will be passed a single argument, which is the instance of
Builtins.namespace (str) – The namespace of the variables to resolve.
timezone (
tzinfo) – A timezone to use when resolving timestamps.value_types (dict) – A mapping of the values to their datatypes.
Changed in version 2.3.0: Added the value_types parameter.
- classmethod from_defaults(values: Mapping[str, Any] | None = None, **kwargs: Any) Builtins[source]
Initialize a
Builtinsinstance with a set of default values.
- resolve_type(name: str) _DataTypeDef[source]
The method to use for resolving the data type of a builtin symbol.
- scope_name = 'built-in'
The identity name of the scope for builtin symbols.