3 ms·
The most obvious way would be to simply annotate the fields, e.g. class Book(MonDoc): title: str = StrField() yearPublished: int = IntField() If thi
by probablyrobert 5y ago
The most obvious way would be to simply annotate the fields, e.g.
class Book(MonDoc):
title: str = StrField()
yearPublished: int = IntField()
If this means too much redundant information for you then you could try defining the fields to return the corresponding python type e.g.
def IntField() -> int:
...
- cabalamat 5y agoI could certainly annotate the fields like you suggest. But that goes against the spirit of Bozen which is DRY. When I define something as a `StrField` I'm already saying it's a string, so I shouldn't have to say it again elsewhere. It would be nice if Python has an API such that I can write code within my `StrField` class that tells python that `title` is a `str`, but to the best of my understanding this doesn't exist.