File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 21
21
TypeVar ,
22
22
cast ,
23
23
final ,
24
- get_origin ,
25
24
runtime_checkable ,
26
25
)
27
26
@@ -93,7 +92,7 @@ def __iter__(self) -> Iterator[Event]:
93
92
94
93
@property
95
94
def origin (self ) -> Event :
96
- return next (self . __iter__ ( ))
95
+ return next (iter ( self ))
97
96
98
97
@property
99
98
def is_circular (self ) -> bool :
@@ -224,10 +223,7 @@ def notify(self, event: Event):
224
223
225
224
@staticmethod
226
225
def __get_origin (cls : type ) -> type :
227
- if origin := get_origin (cls ):
228
- return origin
229
-
230
- return cls
226
+ return getattr (cls , "__origin__" , cls )
231
227
232
228
233
229
"""
Original file line number Diff line number Diff line change 1
1
from dataclasses import dataclass
2
- from typing import Generic , TypeVar
2
+ from typing import Annotated , Generic , TypeVar
3
3
4
4
import pytest
5
5
@@ -30,6 +30,13 @@ def my_function(instance: SomeInjectable):
30
30
31
31
my_function ()
32
32
33
+ def test_inject_with_annotated (self ):
34
+ @inject
35
+ def my_function (instance : Annotated [SomeInjectable , "metadata" ]):
36
+ assert isinstance (instance , SomeInjectable )
37
+
38
+ my_function ()
39
+
33
40
def test_inject_with_positional_only_parameter (self ):
34
41
@inject
35
42
def my_function (instance : SomeInjectable , / , ** kw ):
You can’t perform that action at this time.
0 commit comments