Skip to content

Commit e91f35f

Browse files
committed
Add example for os.environ.setdefault() and envs interpolation
1 parent f77c8b1 commit e91f35f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
section:
2+
option: ${ENV_VAR}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""`Configuration` provider values loading example."""
2+
3+
import os
4+
5+
from dependency_injector import containers, providers
6+
7+
8+
class Container(containers.DeclarativeContainer):
9+
10+
config = providers.Configuration()
11+
12+
13+
if __name__ == '__main__':
14+
os.environ.setdefault('ENV_VAR', 'default value')
15+
16+
container = Container()
17+
container.config.from_yaml('config-with-env-var.yml')
18+
19+
assert container.config.section.option() == 'default value'

0 commit comments

Comments
 (0)