@@ -159,21 +159,19 @@ def evaluate(
159159 type_params = getattr (owner , "__type_params__" , None )
160160
161161 # Type parameters exist in their own scope, which is logically
162- # between the locals and the globals.
163- type_param_scope = {}
162+ # between the locals and the globals. We simulate this by adding
163+ # them to the globals.
164164 if type_params is not None :
165+ globals = dict (globals )
165166 for param in type_params :
166- type_param_scope [param .__name__ ] = param
167-
167+ globals [param .__name__ ] = param
168168 if self .__extra_names__ :
169169 locals = {** locals , ** self .__extra_names__ }
170170
171171 arg = self .__forward_arg__
172172 if arg .isidentifier () and not keyword .iskeyword (arg ):
173173 if arg in locals :
174174 return locals [arg ]
175- elif arg in type_param_scope :
176- return type_param_scope [arg ]
177175 elif arg in globals :
178176 return globals [arg ]
179177 elif hasattr (builtins , arg ):
@@ -185,15 +183,15 @@ def evaluate(
185183 else :
186184 code = self .__forward_code__
187185 try :
188- return eval (code , globals = globals , locals = { ** type_param_scope , ** locals } )
186+ return eval (code , globals = globals , locals = locals )
189187 except Exception :
190188 if not is_forwardref_format :
191189 raise
192190
193191 # All variables, in scoping order, should be checked before
194192 # triggering __missing__ to create a _Stringifier.
195193 new_locals = _StringifierDict (
196- {** builtins .__dict__ , ** globals , ** type_param_scope , ** locals },
194+ {** builtins .__dict__ , ** globals , ** locals },
197195 globals = globals ,
198196 owner = owner ,
199197 is_class = self .__forward_is_class__ ,
0 commit comments