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
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/57NDZA7B3Z4PLGS5JON5YXOP44KI4LVU/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to