Isolate configuration related code better
- create the global `config` object inside the `urban_meal_delivery.configuration` module - streamline documentation and comments
This commit is contained in:
parent
9ee9c04a69
commit
c1064673aa
4 changed files with 12 additions and 16 deletions
|
|
@ -73,7 +73,7 @@ def make_config(env: str = 'production') -> Config:
|
|||
"""Create a new `Config` object.
|
||||
|
||||
Args:
|
||||
env: either 'production' or 'testing'; defaults to the first
|
||||
env: either 'production' or 'testing'
|
||||
|
||||
Returns:
|
||||
config: a namespace with all configurations
|
||||
|
|
@ -81,7 +81,8 @@ def make_config(env: str = 'production') -> Config:
|
|||
Raises:
|
||||
ValueError: if `env` is not as specified
|
||||
""" # noqa:DAR203
|
||||
config: Config
|
||||
config: Config # otherwise mypy is confused
|
||||
|
||||
if env.strip().lower() == 'production':
|
||||
config = ProductionConfig()
|
||||
elif env.strip().lower() == 'testing':
|
||||
|
|
@ -94,3 +95,6 @@ def make_config(env: str = 'production') -> Config:
|
|||
warnings.warn('Bad configurartion: no DATABASE_URI set in the environment')
|
||||
|
||||
return config
|
||||
|
||||
|
||||
config = make_config('testing' if os.getenv('TESTING') else 'production')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue