Add an `optional` flag to `Option.auto` to flag options that do not have defaults as optional
- Vorherrschende Sprache
- Python
- Sterne
- 17
- Forks
- 1
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Look at the Option.auto method in the codebase, likely in a module defining decorators or configuration classes. Understand how validation currently works for options without defaults. The change involves adding a parameter to Option.auto and updating validation logic to treat flagged options as optional. Check existing tests for validation to see how to test the new behavior.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- backend-api-design
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 50/100