Bug report
Bug description:
Resolution of gh-148680 addressed the underlying annotationlib issue without changing the behavior of evaluate_forward_ref.
On 3.14.5:
from annotationlib import Format, get_annotations from typing import TYPE_CHECKING, evaluate_forward_ref def test(arg: Iterable[int]) -> None: pass forward_ref = get_annotations(test, format=Format.FORWARDREF)['arg'] assert forward_ref.evaluate(format=Format.STRING) == 'Iterable[int]' bad_string = evaluate_forward_ref(forward_ref, format=Format.STRING) assert bad_string == 'Iterable[__annotationlib_name_1__]' assert bad_string is forward_ref.__forward_arg__ if TYPE_CHECKING: from collections.abc import Iterable
CPython versions tested on:
3.14
Operating systems tested on:
macOS
Linked PRs
- gh-150641: Fix evaluating forward references in STRING format can 'leak' internal names in
typing#150648 - [3.15] gh-150641: Fix evaluating forward references in STRING format can 'leak' internal names in
typing(GH-150648) #152935 - [3.14] gh-150641: Fix evaluating forward references in STRING format can 'leak' internal names (GH-150648) #153016