Skip to content

Add an optional flag to Option.auto to flag options that do not have defaults as optional #48

@richardhathaway-8451

Description

@richardhathaway-8451

Add an optional (or required, if thinking about it as an inverse) flag to the Option.auto method to allow a user to mark options with no default value as optional.

For example:

@Option.namespace
class FOO:
    A: str


@dataset(dispatch = FOO.A)
def my_dataset():
    return 'default'

@my_dataset.overload(alias = 'overload')
def my_dataset_overload():
    return 'overload'

In this example, FOO.A should be optional, because if a user doesn't provide this option, the default implementation is used. However, doing FOO.validate({}) will fail because validate expects to see FOO.A in the options.

A syntax such as A: str = Option.auto(optional = True) could fix the situation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions