3 ms·
As others have mentioned, one can get some types in python through its own typing module and use a combination of tools for type enforcing and editor intellisen
by barefeg 4y ago
As others have mentioned, one can get some types in python through its own typing module and use a combination of tools for type enforcing and editor intellisense (mypy, pylance, etc.).
However what I’m missing is having more advanced type constructs. For example mapped types, lookup types, etc [1].
That said, it seems like python devs keep adding features over time. For example a couple of years ago it wasn’t possible to specify which fields of a dictionary are required and not required (it required putting required fields in one TypedDict and then subclassing it into another one that had the non required ones with total=False), nor it was possible to “spread” a TypedDict to declare the kwarg types in a function.
[1]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-1.html https://www.typescriptlang.org/docs/handbook/release-notes/t...