Message416155
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 *"? |
|
Date |
User |
Action |
Args |
2022-03-28 09:51:33 | iritkatriel | set | recipients:
+ iritkatriel, docs@python, serhiy.storchaka, veky |
2022-03-28 09:51:33 | iritkatriel | set | messageid: <1648461093.82.0.760677249985.issue26120@roundup.psfhosted.org> |
2022-03-28 09:51:33 | iritkatriel | link | issue26120 messages |
2022-03-28 09:51:33 | iritkatriel | create | |
|