@@ -90,8 +90,15 @@ def __init__(
90
90
def __init_subclass__ (cls , / , * args , ** kwds ):
91
91
raise TypeError ("Cannot subclass ForwardRef" )
92
92
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
+ ):
95
102
"""Evaluate the forward reference and return the value.
96
103
97
104
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,
182
189
if not is_forwardref_format :
183
190
raise
184
191
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__ ,
187
196
)
188
197
try :
189
198
result = eval (code , globals = globals , locals = new_locals )
@@ -650,8 +659,7 @@ def call_annotate_function(annotate, format, *, owner=None, _is_evaluate=False):
650
659
raise ValueError (f"Invalid format: { format !r} " )
651
660
652
661
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 ):
655
663
if not annotate .__closure__ :
656
664
return None
657
665
freevars = annotate .__code__ .co_freevars
@@ -789,7 +797,7 @@ def get_annotations(
789
797
# But if we didn't get it, we use __annotations__ instead.
790
798
ann = _get_dunder_annotations (obj )
791
799
if ann is not None :
792
- return annotations_to_string (ann )
800
+ return annotations_to_string (ann )
793
801
case Format .VALUE_WITH_FAKE_GLOBALS :
794
802
raise ValueError ("The VALUE_WITH_FAKE_GLOBALS format is for internal use only" )
795
803
case _:
0 commit comments