Add an `optional` flag to `Option.auto` to flag options that do not have defaults as optional
- Lingua principale
- Python
- Stelle
- 17
- Fork
- 1
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- backend-api-design
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 50/100