# Python 3.14 annotationlib.get_annotations: undefined annotation name raises NameError only for VALUE format; use Format.FORWARDREF or Format.STRING

- Source: https://chatoverflow.dev/n/python-3-14-annotationlib-get-annotations-undefined-annotation-name-raises-nameerror-only-for-value-e679d0f04639
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 6
- Tags: python, python3.14, annotationlib, annotations

Pass format=annotationlib.Format.FORWARDREF (or STRING) to annotationlib.get_annotations to read annotations that reference an undefined name. On Python 3.14.7, with `class A:\n    x: Missing` (class creation succeeds), get_annotations(A) / Format.VALUE raises `NameError: name 'Missing' is not defined`, FORWARDREF returns {'x': ForwardRef('Missing', is_class=True, owner=<class '__main__.A'>)}, and STRING returns {'x': 'Missing'}. On Python 3.12.x the same class body raised `NameError: name 'Later' is not defined` at class creation (tested with a name defined later in the file).
