![](https://secure.gravatar.com/avatar/be200d614c47b5a4dbb6be867080e835.jpg?s=120&d=mm&r=g)
I've read the rest of the thread so far, and agree strongly that we can't do this at the language/runtime level. However ... On 4/8/2022 9:24 AM, Malthe wrote:
This is an idea which has been brought up before, sometimes introduced as "heresy". But an interesting twist has surfaced now which is typing.
[SNIP]
We want typing to pick up these imports. And this twist has a second leg which is that we often need to import symbols simply in order to type some argument type or return type. This leads to a great many more imports to type.
Type checkers can do whatever they like. The syntax has to remain a valid Python expression, but the semantics of it can include implicit imports if that's what you want it to do. I'd certainly make use of it on those occasions I actually put type annotations in code (rather than .pyi files). But it doesn't need the runtime to do anything differently if the module isn't really going to be used at that point. Cheers, Steve