Best of pydanticOctober 2024

  1. 1
    Article
    Avatar of hnHacker News·2y

    TypedDicts are better than you think

    TypedDict, introduced in PEP-589 for Python 3.8, is a tool for adding type annotations to dictionaries. It addresses limitations of dataclasses, particularly in scenarios like HTTP PATCH operations and handling optional fields. Enhancements like non-totality and individual field requirements improve its flexibility. PEP-692 expanded its application to type keyword arguments, proving useful in functions with numerous optional parameters. TypedDict also aids in dependency injection by defining shared dependencies in one place. Future PEPs aim to introduce features like extra item types and readonly items for even more control.