4 ms·
It's not that it doesn't have type hints, it's that they're really bad. Python decided to introduce the syntax for type hints before developing a type checker (
by phailhaus 3y ago
It's not that it doesn't have type hints, it's that they're really bad. Python decided to introduce the syntax for type hints before developing a type checker (which is still not officially supported). This means that the type system is filled with weird gaps that 3rd party typechecking libraries can't fix without breaking changes to the language itself.
For example, `TypedDict` didn't support optional keys until Python 3.11, and even then you have to use the clunky `NotRequired` type to pull it off. This is despite the fact that having optional kwargs has been a common pattern for decades.
The type system is also not particularly robust. You can't make a class similar to `dataclasses.dataclass` yourself and have it typecheck propertly, so libraries like Pydantic have to develop custom plugins for typecheckers like mypy to get themselves to work.
- giancarlostoro 3y agoAh I see, so you want it improved upon to better align with what has always been available to actually be represented by the option type system, I can agree with that. I'll be honest, I have not used it extensively, I'm used to just doing Python the old way, maybe once its been fully refined and becomes the status quo I'll dive into it. Until then, if I want types I just use a typed language.
- deleted 3y ago[deleted]