On Sun, Feb 14, 2021 at 7:17 PM Inada Naoki <songofaca...@gmail.com> wrote:

> On Mon, Feb 15, 2021 at 10:20 AM Joseph Perez <jope...@hotmail.fr> wrote:
> >
> > > How about having a pseudo-module called __typing__ that is
> > > ignored by the compiler:
> > >
> > > from __typing__ import ...
> > >
> > > would be compiled to a no-op, but recognised by type checkers.
> >
> > If you want to do run-time typing stuff, you would use
> > There is already a way of doing that: `if typing.TYPE_CHECKING: ...`
> https://docs.python.org/3/library/typing.html#typing.TYPE_CHECKING
> > But yes, the issue with it is that this constant is defined in the
> `typing` module …
> >
> > However, I think this is a part of the solution. Indeed, the language
> could define another builtin constants, let's name it `__static__`, which
> would simply be always false (at runtime), while linters/type checkers
> would use it the same way `typing.TYPE_CHECKING` is used:
> > ```python
> > if __static__:
> >     import typing
> >     import expensive_module
> > ```
>
>
> Please note that this is a thread about PEP 649.
>
> If PEP 649 accepted and PEP 563 dies, all such idioms breaks
> annotation completely.
>
> Users need to import all heavy modules and circular references used
> only type hints, or user can not get even string form annotation which
> is very useful for REPLs.
>

Hm, that's a rather serious problem with Larry's PEP 649 compared to `from
__future__ import annotations`, actually.

Larry, what do you think?

-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*
<http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________
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/6BH5YFZP7YRWCI5P7GH44OX775X46FI3/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to