pytroll / pytroll/donfig

Feature request: mark certain config keys as required

Open
#39 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
42
Forks
11
Avg merge
1d 23h
Merged PRs (30d)
2

Description

Is it in scope for Donfig to mark certain config keys as required? My use case is one where I'd like to require a user to specify some keys as part of their local config (like how Git requires you to configure your user name and email).

Two potential APIs that would work for my use case:

  1. Insert a sentinel value into defaults
from donfig import Config, required  # sentinel value

config = Config(
    'my_lib',
    defaults = [{
        'user': {'name': required, 'name': required},
        'foo': {'bar': None},
    }]
)
  1. A separate constructor arg for required keys:
config = Config(
    'my_lib',
    defaults = [{
        'user': {},
        'foo': {'bar': None},
    }],
    required=['user.name', 'user.email']
)

I'd like to raise an error if a user required value is not found in any of the user configs (or environment variables) during setup of the Config class.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the Config class constructor and its setup path, focusing on how defaults, user configs, and environment variables are loaded. Compare the two proposed required-key APIs and define how missing values should be detected and reported during setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.