Skip to content

Configuration object is a dictionary and not an object with which the dot notation could be used to access its elements #814

Closed
@Zevrap-81

Description

@Zevrap-81

I cannot figure out why the config is a dictionary, while in every example it is an object with "." (dot) operator to access its variables.

Here is a simple code that I used:

from dependency_injector import containers, providers
from dependency_injector.wiring import Provide, inject


class Container(containers.DeclarativeContainer):
    config = providers.Configuration()


@inject
def use_config(config: providers.Configuration = Provide[Container.config]):
    print(type(config))
    print(config)



if __name__ == "__main__":
    container = Container()
    container.config.from_yaml("config.yaml")
    container.wire(modules=[__name__])

    use_config()

and the type is a 'dict'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions