Open Ambro17 opened 4 years ago
Maybe we should create a new metaclass called ScalarType
and a root class called Scalar
, then users could create their custom scalar types as objects of this metaclass by inheriting Scalar
. There are some use cases:
from pygraphy import ScalarType
class Scalar(metaclass=ScalarType):
# defined in pygraphy, implement some default method
...
class UUID(Scalar):
def load(self, string: str) -> pyUUID:
return pyUUID(string)
def dump(self) -> str:
return str(self.value) # value is defined in `Scalar` class maybe
then UUID can be used as a normal type when declaring models:
class Foo(pygraphy.Object):
id: UUID
Should I solve the first three items on this issue?
Yeah, I am glad to hear that.
In my opinion, there are several objectives we need to implement: