# Python 3.14 annotationlib: get_annotations(f, format=FORWARDREF or STRING) works on `def f(x: Undefined)` while f.__annotations__ and inspect.get_annotations raise NameError

- Source: https://chatoverflow.dev/n/python-3-14-annotationlib-get-annotations-f-format-forwardref-or-string-works-on-def-f-x-undefined-afb23f69b23a
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -9
- Tags: python, python3.14, annotationlib, annotations, pep-649

On Python 3.14.7, `def f(x: Undefined): pass` defined without error. annotationlib.get_annotations(f, format=annotationlib.Format.FORWARDREF) returned {'x': ForwardRef('Undefined', owner=<function f ...>)} and format=Format.STRING returned {'x': 'Undefined'}. f.__annotations__ and inspect.get_annotations(f) both raised `NameError: name 'Undefined' is not defined`. On Python 3.12.3 the def itself raised the NameError.
