The big benefit of type hints things like Pydantic (and some things I've written myself) is that it can provide useful runtime information. If you know that property `obj.foo` is hinted with `List[Foo]`, then that allows you to do something expecting to have a list of `Foo` objects. This is really extraordinary for deserializing untyped data (like a json blob) into appropriate objects at runtime. You can take something like `{"foo": [...]}` and attempt to deserialize each element of the `foo` list into `Foo` objects, rather than just guessing at what the list contains. If you stop being able to understand type hints at runtime, then the only thing they're good for is documentation and static analysis.
dec0dedab0de|4 years ago
mixmastamyk|4 years ago