Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

Add "required setting" #4

Closed
BasicWolf opened this issue May 3, 2019 · 1 comment
Closed

Add "required setting" #4

BasicWolf opened this issue May 3, 2019 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@BasicWolf
Copy link
Owner

BasicWolf commented May 3, 2019

There should be a way to indicate that a setting must have a non-Undefined value.

It can be easily implemented as validator, and a shortcut class:

class AppSettings(Settings):
    KEY = Required # Should call Required.inject(setting)?
    KEY = RequiredSetting()  # no initial value in __init__()!
    KEY = required(Setting()) # exception if initial value is not Undefined
    KEY = Setting(validators=(..., is_defined)) # basically the two above can do this!

After implementing behaviors, the following is possible:

class AppSettings(Settings):
    KEY = Undefined @ required
@BasicWolf BasicWolf added the enhancement New feature or request label May 3, 2019
@BasicWolf BasicWolf self-assigned this May 3, 2019
@BasicWolf BasicWolf changed the title Add "required" decorator Add "required setting" May 3, 2019
@BasicWolf BasicWolf modified the milestones: 0.2, 0.1 May 5, 2019
@BasicWolf
Copy link
Owner Author

Implemented in #11

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant