builtins

This module contains the class which defines the builtin values for the engine.

class Builtins(values, namespace=None, timezone=None, value_types=None)[source]

Bases: Mapping

A 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, namespace=None, timezone=None, value_types=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=None, **kwargs)[source]

Initialize a Builtins instance with a set of default values.

resolve_type(name)[source]

The method to use for resolving the data type of a builtin symbol.

Parameters:

name (str) – The name of the symbol to retrieve the data type of.

Returns:

The data type of the symbol or UNDEFINED.

scope_name = 'built-in'

The identity name of the scope for builtin symbols.