In short, the idea is simple to add a special variable, available in the global
scope, so you can do this:
if __typing__:
import typing
import another_heavy_typing_lib
It has similar semantics as typing.TYPE_CHECKING, but it would be available in
any context without the need to import anything, just like __name__,
__package__ or __loader__.
By default, it would be false (like False ou None). When running static
checkers and related tools it would be a true value.
Additionally, It would be able to be set (to some value than the default), in
the command line invocation, like `-X typing=someval` or `-X typing`. Maybe
some environment variable too, like PYTHONTYPING. And leaving it as writable
would allow some tool to change it in the runtime.
The name of it could be anything, the `typing` suggestion is just lack of
creativity.
The implementation should be pretty straightforward, it wouldn't have any
impact on existing users, performance, etc. And it would allow to use static
typing in a slight more confident way in regards of worrying with any risk or
penalty about it.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/2G2OCQSM2XEX5JJVJUFZIUE5FYE5NXZS/
Code of Conduct: http://python.org/psf/codeofconduct/