3 ms·
Yes! TypedDict is fantastic for migrating dicts that have outgrown, into more appropriate containers, such as dataclasses. So good in fact that you can often sk
by Too 2y ago
Yes! TypedDict is fantastic for migrating dicts that have outgrown, into more appropriate containers, such as dataclasses. So good in fact that you can often skip step 3 and 4. Assuming the rest of your code has the type annotations wherever such objects are passed through, otherwise the runtime check from the article still has some merit.
- Hackbraten 2y agoGood point, my silent assumption was that the type checker is configured to enforce function signatures to be fully type-annotated. (That's one of the first things I change in the mypy config every time I start a new Python project.)