From 462b13cd48ee48ec483034763f288ee060402df4 Mon Sep 17 00:00:00 2001 From: np-kyokyo Date: Wed, 24 Jan 2024 23:35:51 +0900 Subject: [PATCH] [Docs] update Terminology Injection section --- docs/terminology.rst | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/terminology.rst b/docs/terminology.rst index 26bc8ed..6e34535 100644 --- a/docs/terminology.rst +++ b/docs/terminology.rst @@ -78,7 +78,12 @@ Injection is the process of providing an instance of a type, to a method that us Here is an example of injection on a module provider method, and on the constructor of a normal class:: - from injector import inject + from typing import NewType + + from injector import Binder, Module, inject, provider + + Name = NewType("Name", str) + Description = NewType("Description", str) class User: @inject @@ -86,14 +91,12 @@ Here is an example of injection on a module provider method, and on the construc self.name = name self.description = description - class UserModule(Module): - def configure(self, binder): + def configure(self, binder: Binder): binder.bind(User) - class UserAttributeModule(Module): - def configure(self, binder): + def configure(self, binder: Binder): binder.bind(Name, to='Sherlock') @provider