Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

PEP 649 “Deferred Evaluation Of Annotations Using Descriptors” should result in vastly reducing the need for TYPE_CHECKING.

https://peps.python.org/pep-0649/



I think in practice that increases the need for TYPE_CHECKING. If you use deferred annotations, and you don't import the types you use, type checkers and IDEs will complain, and go to definition won't work. But if you import the types outside of a TYPE_CHECKING block it's wasteful, since you don't actually need the import for your code to run. So you need TYPE_CHECKING to satisfy your linter without impacting runtime performance.


It will also break any runtime typecheck module that you might want to use.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: