Is there a way to import __future__ annotations for all modules in the package?

I naturally thought adding from __future__ import annotations__ to mypkg/ makes all modules capable of using future annotations since the is always ran, but this is not true.

Is there any way to enable future annotations without having to import it on every module? isn’t included in those other modules, it’s executed as its own module. Thus the imports occur in that module, and don’t affect other modules. You can re-export things back out, but then they just need to be imported into the consuming module under another name, so that wouldn’t provide any real benefit.


You need to put it in each module that wants to use it.

1 Like