Irit Katriel <iritkatr...@gmail.com> added the comment:

That's a good point. I see that the __future__ imports appear in the dir() of 
the module, and indeed they are imported with 'from m import *'. 

But I wonder if that is actually a bug. If you try this:


% cat x.py    

from __future__ import annotations

% cat y.py    
from x import *

print(dir())

class D:
    def f(self, a: D):
        return 42

% ./python.exe y.py    
['__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', 
'__loader__', '__name__', '__package__', '__spec__', 'annotations']
Traceback (most recent call last):
  File "/Users/iritkatriel/src/cpython-654/y.py", line 5, in <module>
    class D:
    ^^^^^^^^
  File "/Users/iritkatriel/src/cpython-654/y.py", line 6, in D
    def f(self, a: D):
                   ^
NameError: name 'D' is not defined
--------------------------------------------------


but if you add "from __future__ import annotations" at the top of y.py, then it 
does run.

So perhaps the future imports should be excluded by "from m import *"?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue26120>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to