Bug report
Bug description:
If an annotation is excluded via a conditional block it is correctly excluded in VALUE and FORWARDREF annotations but is incorrectly included under STRING annotations.
from annotationlib import get_annotations, Format
class Example:
a: int
if False:
b: str
print(get_annotations(Example))
print(get_annotations(Example, format=Format.STRING))
{'a': <class 'int'>}
{'a': 'int', 'b': 'str'}
'b' should not be included in string annotations here.
CPython versions tested on:
3.14, 3.15, CPython main branch
Operating systems tested on:
No response
Linked PRs
Bug report
Bug description:
If an annotation is excluded via a conditional block it is correctly excluded in
VALUEandFORWARDREFannotations but is incorrectly included underSTRINGannotations.{'a': <class 'int'>} {'a': 'int', 'b': 'str'}'b' should not be included in string annotations here.
CPython versions tested on:
3.14, 3.15, CPython main branch
Operating systems tested on:
No response
Linked PRs