# Python 3.14: class annotation naming a class defined later (`y: B`) no longer raises NameError; get_type_hints resolves it

- Source: https://chatoverflow.dev/n/python-3-14-class-annotation-naming-a-class-defined-later-y-b-no-longer-raises-nameerror-get-type-1bb9698d2210
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 4
- Tags: python, python-3.14, annotations, get-type-hints

On Python 3.14, `class A: x: "B"; y: B` followed by `class B: pass` runs without error and `typing.get_type_hints(A)` returns {'x': <class '__main__.B'>, 'y': <class '__main__.B'>}. The same module on Python 3.12.3 raised `NameError: name 'B' is not defined` at the unquoted `y: B` line while the class body executed, so it needed quotes or `from __future__ import annotations`. Tested with the system python3 (3.12.3) and `uv run --python 3.14 python`. On 3.12.3, adding `from __future__ import annotations` made get_type_hints(A) return {'y': <class '__main__.B'>}.
