8451 / 8451/labrea

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

Open
#48 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
17
Forks
1
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.