errors
This module contains the exceptions raised by the package.
Data
- UNDEFINED = UNDEFINED
A sentinel value to specify that something is undefined. When evaluated, the value is falsy.
Added in version 2.0.0.
Exceptions
- exception ArithmeticError(message: str = '')[source]
Bases:
EvaluationErrorAn error raised when there is an issue performing an arithmetic operation.
Added in version 5.0.0.
- exception AttributeResolutionError(attribute_name: str, object_: Any, thing: Any = UNDEFINED, suggestion: str | None = None)[source]
Bases:
EvaluationErrorAn error raised when an attribute can not be resolved to a value.
Added in version 2.0.0.
- __init__(attribute_name: str, object_: Any, thing: Any = UNDEFINED, suggestion: str | None = None) None[source]
- Parameters:
Changed in version 3.2.0: Added the suggestion parameter.
- attribute_name
The name of the symbol that can not be resolved.
- object
The value that attribute_name was used as an attribute for.
- suggestion
An optional suggestion for a valid attribute name.
- thing
The root-object that was used to resolve object.
- exception AttributeTypeError(attribute_name: str, object_type: _DataTypeDef, is_value: Any, is_type: _DataTypeDef, expected_type: _DataTypeDef)[source]
Bases:
EvaluationErrorAn error raised when an attribute with type information is resolved to a Python value that is not of that type.
- __init__(attribute_name: str, object_type: _DataTypeDef, is_value: Any, is_type: _DataTypeDef, expected_type: _DataTypeDef) None[source]
- Parameters:
attribute_name (str) – The name of the symbol that can not be resolved.
object_type – The value that attribute_name was used as an attribute for.
is_value – The native Python value of the incompatible attribute.
is_type – The
rule-engine typeof the incompatible attribute.expected_type – The
rule-engine typethat was expected for this attribute.
- attribute_name
The name of the attribute that is of an incompatible type.
- expected_type
The
rule-engine typethat was expected for this attribute.
- is_type
The
rule-engine typeof the incompatible attribute.
- is_value
The native Python value of the incompatible attribute.
- object_type
The object on which the attribute was resolved.
- exception BytesSyntaxError(message: str, value: str)[source]
Bases:
SyntaxErrorAn error raised for issues regarding the use of improperly formatted bytes expressions.
Added in version 4.5.0.
- value
The bytes value which contains the syntax error which caused this exception to be raised.
- exception DatetimeSyntaxError(message: str, value: str)[source]
Bases:
SyntaxErrorAn error raised for issues regarding the use of improperly formatted datetime expressions.
- value
The datetime value which contains the syntax error which caused this exception to be raised.
- exception FloatSyntaxError(message: str, value: str)[source]
Bases:
SyntaxErrorAn error raised for issues regarding the use of improperly formatted float expressions.
Added in version 4.0.0.
- value
The float value which contains the syntax error which caused this exception to be raised.
- exception EngineError(message: str = '')[source]
Bases:
ExceptionThe base exception class from which other exceptions within this package inherit.
- __init__(message: str = '') None[source]
- Parameters:
message (str) – A text description of what error occurred.
- message
A text description of what error occurred.
- exception EvaluationError(message: str = '')[source]
Bases:
EngineErrorAn error raised for issues which occur while the rule is being evaluated. This can occur at parse time while AST nodes are being evaluated during the reduction phase.
- exception FunctionCallError(message: str, error: BaseException | None = None, function_name: str | None = None)[source]
Bases:
EvaluationErrorAn error raised when there is an issue calling a function.
Added in version 4.0.0.
- __init__(message: str, error: BaseException | None = None, function_name: str | None = None) None[source]
- Parameters:
message (str) – A text description of what error occurred.
- error
The exception from which this error was triggered.
- exception LookupError(container: Any, item: Any)[source]
Bases:
EvaluationErrorAn error raised when a lookup operation fails to obtain and item from a container. This is analogous to a combination of Python’s builtin
IndexErrorandKeyErrorexceptions.Added in version 2.4.0.
- __init__(container: Any, item: Any) None[source]
- Parameters:
container – The container object that the lookup was performed on.
item – The item that was used as either the key or index of container for the lookup.
- container
The container object that the lookup was performed on.
- item
The item that was used as either the key or index of container for the lookup.
- exception MappingAttributeLookupDeprecation[source]
Bases:
DeprecationWarningA
DeprecationWarningsubclass emitted when a rule accesses an attribute on aMAPPINGvalue via dot syntax, falling back to key-style lookup. The fallback is scheduled for removal in v6.0; migrate tomapping['key']syntax or construct theContextwithmapping_attribute_lookup=Falseto opt out now. Filter this class viawarningsto silence the notice during the transition window.Added in version 5.0.0.
- exception ObjectAttributeError(attribute_name: str, object_: Any, thing: Any = UNDEFINED, suggestion: str | None = None)[source]
Bases:
AttributeResolutionErrorAn error raised when an attribute can not be resolved against an
OBJECTschema. This is a subclass ofAttributeResolutionErrorso existing handlers keep working, but it lets users identify schema-driven lookup failures specifically.Added in version 5.0.0.
- exception RegexSyntaxError(message: str, error: error, value: str)[source]
Bases:
SyntaxErrorAn error raised for issues regarding the use of improper regular expression syntax.
- value
The regular expression value which contains the syntax error which caused this exception to be raised.
- exception RuleSyntaxError(message: str, token: Any = None)[source]
Bases:
SyntaxErrorAn error raised for issues identified while parsing the grammar of the rule text.
- __init__(message: str, token: Any = None) None[source]
- Parameters:
message (str) – A text description of what error occurred.
token – The PLY token (if available) which is related to the syntax error.
- token
The PLY token (if available) which is related to the syntax error.
- exception StringSyntaxError(message: str, value: str)[source]
Bases:
SyntaxErrorAn error raised for issues regarding the use of improperly formatted string expressions.
Added in version 4.5.0.
- value
The string value which contains the syntax error which caused this exception to be raised.
- exception SymbolResolutionError(symbol_name: str, symbol_scope: str | None = None, thing: Any = UNDEFINED, suggestion: str | None = None)[source]
Bases:
EvaluationErrorAn error raised when a symbol name is not able to be resolved to a value.
- __init__(symbol_name: str, symbol_scope: str | None = None, thing: Any = UNDEFINED, suggestion: str | None = None) None[source]
- Parameters:
Changed in version 2.0.0: Added the thing parameter.
Changed in version 3.2.0: Added the suggestion parameter.
- suggestion
An optional suggestion for a valid symbol name.
- symbol_name
The name of the symbol that can not be resolved.
- symbol_scope
The scope of where the symbol should be valid for resolution.
- thing
The root-object that was used to resolve the symbol.
- exception SymbolTypeError(symbol_name: str, is_value: Any, is_type: _DataTypeDef, expected_type: _DataTypeDef)[source]
Bases:
EvaluationErrorAn error raised when a symbol with type information is resolved to a Python value that is not of that type.
- __init__(symbol_name: str, is_value: Any, is_type: _DataTypeDef, expected_type: _DataTypeDef) None[source]
- Parameters:
symbol_name (str) – The name of the symbol that is of an incompatible type.
is_value – The native Python value of the incompatible symbol.
is_type – The
rule-engine typeof the incompatible symbol.expected_type – The
rule-engine typethat was expected for this symbol.
- expected_type
The
rule-engine typethat was expected for this symbol.
- is_type
The
rule-engine typeof the incompatible symbol.
- is_value
The native Python value of the incompatible symbol.
- symbol_name
The name of the symbol that is of an incompatible type.
- exception SyntaxError(message: str = '')[source]
Bases:
EngineErrorA base error for syntax related issues.
- exception TimedeltaSyntaxError(message: str, value: str)[source]
Bases:
SyntaxErrorAn error raised for issues regarding the use of improperly formatted timedelta expressions.
Added in version 3.5.0.
- value
The timedelta value which contains the syntax error which caused this exception to be raised.
Exception Hierarchy
The class hierarchy for Rule Engine exceptions is:
EngineError
+-- EvaluationError
+-- ArithmeticError
+-- AttributeResolutionError
+-- ObjectAttributeError
+-- AttributeTypeError
+-- FunctionCallError
+-- LookupError
+-- SymbolResolutionError
+-- SymbolTypeError
+-- SyntaxError
+-- BytesSyntaxError
+-- DatetimeSyntaxError
+-- FloatSyntaxError
+-- RegexSyntaxError
+-- RuleSyntaxError
+-- StringSyntaxError
+-- TimedeltaSyntaxError
DeprecationWarning
+-- MappingAttributeLookupDeprecation