Bug report
Bug description:
Tested on 3.14.0a1 - related to implementation of PEP 649 / PEP 749 - #119180
If a type uses dotted access but can't be evaluated, get_annotations returns _Stringifier objects instead of ForwardRef objects.
from annotationlib import get_annotations, Format
class Example:
dotted: typing.Any
undotted: Any
ann = get_annotations(Example, format=Format.FORWARDREF)
for name, value in ann.items():
print(f"{name!r}: {value!r} | type: {type(value)!r}")
Output:
'dotted': typing.Any | type: <class 'annotationlib._Stringifier'>
'undotted': ForwardRef('Any') | type: <class 'annotationlib.ForwardRef'>
I'd expect to see ForwardRef('typing.Any') here so this was surprising. I also found another bug related to dotted access but not related to Stringifiers that I'll raise separately.
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs