mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-29 21:14:00 +03:00
26 lines
444 B
Python
26 lines
444 B
Python
"""Wiring string id example."""
|
|
|
|
from dependency_injector import containers, providers
|
|
from dependency_injector.wiring import Provide, inject
|
|
|
|
|
|
class Service:
|
|
...
|
|
|
|
|
|
class Container(containers.DeclarativeContainer):
|
|
|
|
service = providers.Factory(Service)
|
|
|
|
|
|
@inject
|
|
def main(service: Service = Provide["service"]) -> None:
|
|
...
|
|
|
|
|
|
if __name__ == "__main__":
|
|
container = Container()
|
|
container.wire(modules=[__name__])
|
|
|
|
main()
|