@@ -90,8 +90,15 @@ def __init__(
9090 def __init_subclass__ (cls , / , * args , ** kwds ):
9191 raise TypeError ("Cannot subclass ForwardRef" )
9292
93- def evaluate (self , * , globals = None , locals = None , type_params = None , owner = None ,
94- format = Format .VALUE ):
93+ def evaluate (
94+ self ,
95+ * ,
96+ globals = None ,
97+ locals = None ,
98+ type_params = None ,
99+ owner = None ,
100+ format = Format .VALUE ,
101+ ):
95102 """Evaluate the forward reference and return the value.
96103
97104 If the forward reference cannot be evaluated, raise an exception.
@@ -182,8 +189,10 @@ def evaluate(self, *, globals=None, locals=None, type_params=None, owner=None,
182189 if not is_forwardref_format :
183190 raise
184191 new_locals = _StringifierDict (
185- {** builtins .__dict__ , ** locals }, globals = globals , owner = owner ,
186- is_class = self .__forward_is_class__
192+ {** builtins .__dict__ , ** locals },
193+ globals = globals ,
194+ owner = owner ,
195+ is_class = self .__forward_is_class__ ,
187196 )
188197 try :
189198 result = eval (code , globals = globals , locals = new_locals )
@@ -650,8 +659,7 @@ def call_annotate_function(annotate, format, *, owner=None, _is_evaluate=False):
650659 raise ValueError (f"Invalid format: { format !r} " )
651660
652661
653- def _build_closure (annotate , owner , is_class , stringifier_dict , * ,
654- allow_evaluation ):
662+ def _build_closure (annotate , owner , is_class , stringifier_dict , * , allow_evaluation ):
655663 if not annotate .__closure__ :
656664 return None
657665 freevars = annotate .__code__ .co_freevars
@@ -789,7 +797,7 @@ def get_annotations(
789797 # But if we didn't get it, we use __annotations__ instead.
790798 ann = _get_dunder_annotations (obj )
791799 if ann is not None :
792- return annotations_to_string (ann )
800+ return annotations_to_string (ann )
793801 case Format .VALUE_WITH_FAKE_GLOBALS :
794802 raise ValueError ("The VALUE_WITH_FAKE_GLOBALS format is for internal use only" )
795803 case _:
0 commit comments