Added type value constants
This commit is contained in:
parent
f6747c6929
commit
5a548d5c3e
1 changed files with 9 additions and 2 deletions
|
|
@ -3,7 +3,14 @@ from typing import Any, List, Tuple, Optional, Union
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
primitive_types = (int, float, str, bool)
|
primitive_types = (int, float, str, bool)
|
||||||
type_values = ("Integer", "Float", "String", "Boolean", "Type")
|
INTEGER = {"type": "Integer"}
|
||||||
|
FLOAT = {"type": "Float"}
|
||||||
|
STRING = {"type": "String"}
|
||||||
|
BOOLEAN = {"type": "Boolean"}
|
||||||
|
TYPE = {"type": "Type"}
|
||||||
|
NODE = {"type": "Node"}
|
||||||
|
EDGE = {"type": "Edge"}
|
||||||
|
type_values = (INTEGER, FLOAT, STRING, BOOLEAN, TYPE, NODE, EDGE)
|
||||||
|
|
||||||
|
|
||||||
Node = str
|
Node = str
|
||||||
|
|
@ -37,7 +44,7 @@ class State(ABC):
|
||||||
Returns:
|
Returns:
|
||||||
True if value type is supported, False otherwise.
|
True if value type is supported, False otherwise.
|
||||||
"""
|
"""
|
||||||
if isinstance(value, dict) and value.get("type", None) in type_values:
|
if isinstance(value, dict) and value in type_values:
|
||||||
return True
|
return True
|
||||||
if not isinstance(value, primitive_types):
|
if not isinstance(value, primitive_types):
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue