__typing__: new top level special variable to indicate typing enabled
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.
participants (1)
-
rea.aft@gmail.com