File tree Expand file tree Collapse file tree 4 files changed +95
-66
lines changed
Expand file tree Collapse file tree 4 files changed +95
-66
lines changed Original file line number Diff line number Diff line change @@ -89,8 +89,16 @@ def standardize_types(
8989 else :
9090 yield tp
9191
92- if with_origin and origin is not None :
93- yield origin
92+ if with_origin :
93+ if origin is not None :
94+ yield origin
95+
96+ for alias in (tp , origin ):
97+ if isinstance (alias , TypeAliasType ):
98+ yield from standardize_types (
99+ alias .__value__ ,
100+ with_origin = with_origin ,
101+ )
94102
95103 continue
96104
Original file line number Diff line number Diff line change @@ -347,8 +347,8 @@ def __keep_new_record[T](
347347 @staticmethod
348348 def __standardize_inputs [T ](
349349 classes : Iterable [InputType [T ]],
350- ) -> Iterable [InputType [T ]]:
351- return tuple ( standardize_types (* classes , with_origin = True ) )
350+ ) -> Iterator [InputType [T ]]:
351+ return standardize_types (* classes , with_origin = True )
352352
353353 @staticmethod
354354 def __update_preprocessing [T ](updater : Updater [T ]) -> Updater [T ]:
Original file line number Diff line number Diff line change @@ -194,3 +194,24 @@ def update(self):
194194
195195 a = get_instance (A )
196196 assert isinstance (a , A )
197+
198+ def test_injectable_with_type_alias_type (self ):
199+ @injectable
200+ class A : ...
201+
202+ type Alias1 = A
203+ type Alias2 = Alias1
204+
205+ a1 = get_instance (Alias1 )
206+ a2 = get_instance (Alias2 )
207+ assert isinstance (a1 , A )
208+ assert isinstance (a2 , A )
209+
210+ def test_injectable_with_generic_type_alias_type (self ):
211+ @injectable
212+ class A [T ]: ...
213+
214+ type Alias [T ] = A [T ]
215+
216+ a = get_instance (Alias [int ])
217+ assert isinstance (a , A )
You can’t perform that action at this time.
0 commit comments