You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pyrepl always has from __future__ import annotations on #119443
% ./python.exe
Python 3.14.0a0 (heads/main:e12a6780bb, May 22 2024, 13:54:40) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(x: y): pass
...
>>> f.__annotations__
{'x': 'y'}
This likely happens because the code is exec()'ed in a file that has the future import; exec() inherits the __future__ state from the file where it's called (a questionable feature but that's how it is).
There's a related issue where it is impossible to turn a future import on in the REPL, because every line is compiled separately, and the future imports from the previous one are forgotten when the next one runs.
Activity
pythongh-119443: Turn off from __future__ import annotations in REPL
JelleZijlstra commentedon May 24, 2024
There's a related issue where it is impossible to turn a future import on in the REPL, because every line is compiled separately, and the future imports from the previous one are forgotten when the next one runs.
pythongh-119443: Turn off from __future__ import annotations in REPL
gh-119443: Turn off from __future__ import annotations in REPL (#119493)
pythongh-119443: Turn off from __future__ import annotations in REPL (p…
[3.13] gh-119443: Turn off from __future__ import annotations in REPL (…
pythongh-119443: Turn off from __future__ import annotations in REPL (p…