-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Description
Currently, when a ForwardRef is successfully evaluated, we store the resulting value and on subsequent calls return it immediately, regardless of the arguments passed to ForwardRef.evaluate().
This is currently implemented here:
Line 100 in a472244
if self.__forward_evaluated__: |
It matches previous behavior in 3.13:
Line 1053 in 8b4a0d6
if not self.__forward_evaluated__ or localns is not globalns: |
I think this is confusing: if you call evaluate() on a ForwardRef that was already evaluated, we ignore whatever globals/locals/type_params you pass in and return whatever the result of the previous evaluation was. It would make more sense to me for evaluate() to re-evaluate the ForwardRef every time it is called. Callers can add caching if they want to in a more intelligent way.
As for #129463, cc @agronholm @Viicos @leycec.