Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting BaseObj need and optional params via dictionary #17

Open
ramaro opened this issue Dec 6, 2021 · 0 comments
Open

Allow setting BaseObj need and optional params via dictionary #17

ramaro opened this issue Dec 6, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@ramaro
Copy link
Member

ramaro commented Dec 6, 2021

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

@ramaro ramaro added the enhancement New feature or request label Dec 6, 2021
@ramaro ramaro self-assigned this Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant