4 ms·
Type hinting in Python is so ugly that I stripped it all out after a few days of using it on some personal projects. They more than double the length of functio
by sleavey 8y ago
Type hinting in Python is so ugly that I stripped it all out after a few days of using it on some personal projects. They more than double the length of function signatures and create comment clutter (is this a real comment or some MyPy flag?).
I wish there was a way to fully separate the hints into separate files. Such files could act like header files in C. Or, some comment character other than # to start type hint (how about "!"?), so IDEs can hide them if the user wants.
- pjtr 8y agoIsn't that exactly what is possible with "3. Interface stub files"? https://www.bernat.tech/the-state-of-type-hints-in-python/#3interfacestubfiles https://www.bernat.tech/the-state-of-type-hints-in-python/#3...
- sleavey 8y agoThese don't support full separation [1]. Some type hints must be in the main source file. [1] https://stackoverflow.com/questions/47350570/is-it-possible-to-separate-all-type-hinting-checking-infrastructure-in-python https://stackoverflow.com/questions/47350570/is-it-possible-...
- cdancette 8y agoyou can type hint without comments a: int = 1 is valid python