This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author iritkatriel
Recipients docs@python, iritkatriel, serhiy.storchaka, veky
Date 2022-03-28.09:51:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1648461093.82.0.760677249985.issue26120@roundup.psfhosted.org>
In-reply-to
Content
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 *"?
History
Date User Action Args
2022-03-28 09:51:33iritkatrielsetrecipients: + iritkatriel, docs@python, serhiy.storchaka, veky
2022-03-28 09:51:33iritkatrielsetmessageid: <1648461093.82.0.760677249985.issue26120@roundup.psfhosted.org>
2022-03-28 09:51:33iritkatriellinkissue26120 messages
2022-03-28 09:51:33iritkatrielcreate