27 lines
506 B
Python
27 lines
506 B
Python
from typing import Any, Generic, TypeVar
|
|
|
|
T = TypeVar('T')
|
|
|
|
|
|
class BaseValue(Generic[T]):
|
|
__slots__ = ('data', )
|
|
|
|
data: T
|
|
|
|
def __init__(self, data: T) -> None:
|
|
self.data = data
|
|
|
|
def __eq__(self, other: Any) -> bool:
|
|
return self.__class__ is other.__class__ and self.data == other.data
|
|
|
|
def __repr__(self) -> str:
|
|
return f'{self.__class__.__name__}({repr(self.data)})'
|
|
|
|
|
|
class UntypedValue(BaseValue[Any]):
|
|
pass
|
|
|
|
|
|
class BytesValue(BaseValue[bytes]):
|
|
pass
|