Skip to content
Prev Previous commit
Next Next commit
simplify
  • Loading branch information
AlexWaygood committed Jun 9, 2024
commit bccaea2f237699fd3be6db9ab4646ac61e28f28a
12 changes: 6 additions & 6 deletions Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,15 +1069,15 @@ def _evaluate(self, globalns, localns, type_params=_sentinel, *, recursive_guard
# but should in turn be overridden by names in the class scope
# (which here are called `globalns`!)
if type_params:
name_to_param_map = {param.__name__: param for param in type_params}
if self.__forward_is_class__:
globalns, localns = dict(globalns), dict(localns)
for name, param in name_to_param_map.items():
if name not in globalns:
globalns[name] = param
localns.pop(name, None)
for param in type_params:
param_name = param.__name__
if param_name not in globalns:
Comment thread
AlexWaygood marked this conversation as resolved.
Outdated
globalns[param_name] = param
localns.pop(param_name, None)
else:
localns = name_to_param_map | localns
localns = {param.__name__: param for param in type_params} | localns

type_ = _type_check(
eval(self.__forward_code__, globalns, localns),
Expand Down