Skip to content

Allow setting BaseObj need and optional params via dictionary #17

@ramaro

Description

@ramaro

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions