From 79e787887cc666339e7b02d4878057ced7af3761 Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Tue, 10 Dec 2019 01:18:28 +0100 Subject: [PATCH] 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. --- injector/__init__.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/injector/__init__.py b/injector/__init__.py index 2d9c226..dad96ab 100644 --- a/injector/__init__.py +++ b/injector/__init__.py @@ -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 `_ (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::