Giter Club home page Giter Club logo

bestconfig's People

Contributors

fivol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

chernogorsky

bestconfig's Issues

Traceback can be more helpful when KeyError is raised

Right now it is hard to determine what config parameter is absent in .env or any other config sources.

Feature request: Add information about what parameter is missing like "KeyError: couldn't find source for config parameter TOKEN_1"

Example (how traceback looks in current version):

>>> import bestconfig
>>> config = bestconfig.Config()
>>> 
>>> def f():
...     ...
...     ...
...     a = config['TOKEN_1']
...     ...
...     b = config['TOKEN_2']
...     ...
... 
>>> f()
Traceback (most recent call last):
  File "/home/m-danya/code/public-habit-tracker/venv/lib/python3.10/site-packages/bestconfig/config_provider.py", line 56, in get
    value = self._unsafe_access_key(item)
  File "/home/m-danya/code/public-habit-tracker/venv/lib/python3.10/site-packages/bestconfig/config_provider.py", line 182, in _unsafe_access_key
    raise KeyError
KeyError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 4, in f
  File "/home/m-danya/code/public-habit-tracker/venv/lib/python3.10/site-packages/bestconfig/config_provider.py", line 158, in __getitem__
    return self.get(item, raise_absent=True)
  File "/home/m-danya/code/public-habit-tracker/venv/lib/python3.10/site-packages/bestconfig/config_provider.py", line 67, in get
    raise KeyError
KeyError

For now, is it impossible to determine whether TOKEN_1 or TOKEN_2 is absent. This feature would greatly improve this package. Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.