It is not always ideal to hardcode every BaseObj argument via self.need()
or self.optional()
.
Passing a dictionary to define these can be useful:
class Mountain(BaseObj):
def new(self):
self.args(
{
"need": {"height": {"type": int, "msg": "height is an int"}},
"optional": {
"has_snow": {
"type": Boolean,
"default": False,
"msg": "has_now is a Boolean",
}
},
}
)
Alternatively, self.args
can also be a BaseObj