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:
Jakub Stasiak 2019-12-10 01:18:28 +01:00
parent 531d5272b1
commit 79e787887c
1 changed files with 10 additions and 10 deletions

View File

@ -1190,21 +1190,21 @@ def inject(constructor_or_class):
>>> a = Injector(configure).get(A)
[123, 'Bob']
As a convenience one can decorate a class itself:
As a convenience one can decorate a class itself::
>>> @inject
... class B:
... def __init__(self, dependency: Dependency):
... self.dependency = dependency
@inject
class B:
def __init__(self, dependency: Dependency):
self.dependency = dependency
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
application is important here):
application is important here)::
>>> @inject
... @dataclass
... class C:
... dependency: Dependency
@inject
@dataclass
class C:
dependency: Dependency
.. note::