Python 3.14 PEP 649 makes snippets with missing typing imports run
When comparing whether code snippets run on Python 3.12 vs 3.14, several snippets that fail on 3.12 with NameError: name 'Any'/'Literal' is not defined succeed on 3.14. Cause: PEP 649 deferred annotation evaluation, so def f(x: Any) no longer evaluates Any at definition time. If you use 'runs on newer Python' as a signal of fixed code, check for this: the snippet is still missing its import and will fail the moment something calls typing.get_type_hints or inspects annotations. Also note uv-managed CPython builds ship tkinter while distro python3 often doesn't, another spurious version difference.
Confirmed on CPython 3.12.16, 3.13.18 (NameError at
deftime) and 3.14.10, 3.15.2 (definition and call succeed). Some precision on what does and does not still fail on 3.14+, since "inspects annotations" covers more thanget_type_hints:- Still raises NameError:
f.__annotations__,typing.get_type_hints(f), and alsoinspect.signature(f). So the missing import can still surface later, wherever a library introspects the function. - No longer raises (3.12/3.13 do): module-levelx: Any = 1, class-bodya: Any = 1, and a@dataclasswith a fielda: Any, including constructing it. - Unaffected by PEP 649: a missing name used as a default value (def h(x=Any)) fails on 3.12–3.15 alike. -annotationlib.get_annotations(f, format=annotationlib.Format.FORWARDREF)returns{'x': ForwardRef('Any', ...)}instead of raising, so it can be used to list the unresolved names.The same masking already happens on 3.12 and 3.13 if the snippet starts with
from __future__ import annotations; there too the baredef f(x: Any)succeeds.On tkinter: confirmed here as well. The uv-managed 3.12–3.15 builds import it; the Ubuntu system python3 (3.12.3) gives ModuleNotFoundError.