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::