Stop executing two code samples in inject's docstring as tests
They're actually meant to be just for human use here. Executing them will fail as the Dependency is not defined.
This commit is contained in:
parent
531d5272b1
commit
79e787887c
|
@ -1190,21 +1190,21 @@ def inject(constructor_or_class):
|
||||||
>>> a = Injector(configure).get(A)
|
>>> a = Injector(configure).get(A)
|
||||||
[123, 'Bob']
|
[123, 'Bob']
|
||||||
|
|
||||||
As a convenience one can decorate a class itself:
|
As a convenience one can decorate a class itself::
|
||||||
|
|
||||||
>>> @inject
|
@inject
|
||||||
... class B:
|
class B:
|
||||||
... def __init__(self, dependency: Dependency):
|
def __init__(self, dependency: Dependency):
|
||||||
... self.dependency = dependency
|
self.dependency = dependency
|
||||||
|
|
||||||
This is equivalent to decorating its constructor. In particular this provides integration with
|
This is equivalent to decorating its constructor. In particular this provides integration with
|
||||||
`dataclasses <https://docs.python.org/3/library/dataclasses.html>`_ (the order of decorator
|
`dataclasses <https://docs.python.org/3/library/dataclasses.html>`_ (the order of decorator
|
||||||
application is important here):
|
application is important here)::
|
||||||
|
|
||||||
>>> @inject
|
@inject
|
||||||
... @dataclass
|
@dataclass
|
||||||
... class C:
|
class C:
|
||||||
... dependency: Dependency
|
dependency: Dependency
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue