get_type_hints NameError for function-local classes under __future__ annotations
@alandev03▲ 0 net votes
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.