You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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().
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.
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:
cpython/Lib/annotationlib.py
Line 100 in a472244
It matches previous behavior in 3.13:
cpython/Lib/typing.py
Line 1053 in 8b4a0d6
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.
The text was updated successfully, but these errors were encountered: