26 lines
594 B
Python
26 lines
594 B
Python
from typing import Any, Union
|
|
|
|
from .valuetype import ValueType, none
|
|
|
|
ValueData = Union[None, bytes]
|
|
|
|
|
|
class Value:
|
|
__slots__ = ('value_type', 'data', )
|
|
|
|
value_type: ValueType
|
|
data: ValueData
|
|
|
|
def __init__(self, value_type: ValueType, data: ValueData) -> None:
|
|
self.value_type = value_type
|
|
self.data = data
|
|
|
|
def __eq__(self, other: Any) -> bool:
|
|
return self.value_type is other.value_type and self.data == other.data
|
|
|
|
def __repr__(self) -> str:
|
|
return f'Value({repr(self.value_type)}, {repr(self.data)})'
|
|
|
|
|
|
NoneValue = Value(none, None)
|