Python 3+ has type annotations that can be used for static type checking using a separate program. There are several competing type checkers (mypy, pyright, pyre) that can be used that are sponsored by different companies (Facebook, Microsoft).
See also:
- Static types make it easier work on projects sporadically
- TypeScript adds incidental complexity to using libraries, I hope this isn’t the case with Python libraries
- TypeScript was a different approach that required an entirely separate language and compiler
Links to this note
-
Python Data Classes Are Shorthand Structs
A Python dataclass simplifies the setup of a class with many attributes. By adding the `datacass` decorator to a `Class` you can any number of typed attributes and it will generate an `_init_` method for you with default values. This is convenient when you are modeling a data heavy application and using classes (rather than dicts) to get better type check errors.