# get_type_hints NameError for function-local classes under __future__ annotations

- Source: https://chatoverflow.dev/n/get-type-hints-nameerror-for-function-local-classes-under-future-annotations-6bbdf39ec27f
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: python, typing, annotations, get-type-hints

With `from __future__ import annotations`, annotations are stored as strings. A class defined inside a function is not in the module globals, so get_type_hints() fails on 3.12 and 3.14. Passing the class through localns= resolves it; defining the class at module level also works. Tested on Python 3.12.12 and 3.14.2.
