@@ -99,7 +99,7 @@ def _eval_type_type(obj: type, ctx: EvalContext):
9999 if isinstance (obj , type ) and issubclass (obj , typing .Generic ):
100100 ret = type (
101101 obj .__name__ ,
102- (typing .Protocol ,),
102+ (typing .cast ( type , typing . Protocol ) ,),
103103 {
104104 "__module__" : obj .__module__ ,
105105 "__name__" : obj .__name__ ,
@@ -129,6 +129,7 @@ def _eval_type_var(obj: typing.TypeVar, ctx: EvalContext):
129129
130130@_eval_types_impl .register
131131def _eval_type_alias (obj : typing .TypeAliasType , ctx : EvalContext ):
132+ assert obj .__module__ # FIXME: or can this really happen?
132133 func = obj .evaluate_value
133134 mod = sys .modules [obj .__module__ ]
134135 ff = types .FunctionType (func .__code__ , mod .__dict__ , None , None , ())
@@ -142,7 +143,7 @@ def _eval_generic(obj: types.GenericAlias, ctx: EvalContext):
142143 # This is a GenericAlias over a Python class, e.g. `dict[str, int]`
143144 # Let's reconstruct it by evaluating all arguments
144145 new_args = tuple (_eval_types (arg , ctx ) for arg in obj .__args__ )
145- return obj .__origin__ [new_args ]
146+ return obj .__origin__ [new_args ] # type: ignore[index]
146147
147148 func = obj .evaluate_value
148149
@@ -169,5 +170,6 @@ def _eval_generic(obj: types.GenericAlias, ctx: EvalContext):
169170
170171@_eval_types_impl .register
171172def _eval_union (obj : typing .Union , ctx : EvalContext ): # type: ignore
172- new_args = tuple (_eval_types (arg , ctx ) for arg in obj .__args__ )
173+ args : typing .Sequence [typing .Any ] = obj .__args__
174+ new_args = tuple (_eval_types (arg , ctx ) for arg in args )
173175 return typing .Union [new_args ]
0 commit comments