[note] Enhancing Code Clarity with TypedDict
The reason why we meed to use TypedDict
In general, we use dataclasses and Pydantic to store data. However, using dictionaries to store complex data is often an easier approach. Nevertheless, without predefined fields, it becomes difficult for later developers to maintain the code effectively. Using TypedDict
allows the IDE to provide developers with suggestions, enhancing their development efficiency. But, TypedDict
have some limitations; it cannot enforce strict type checking.
1 | from typing import TypedDict |
Reference
[note] Enhancing Code Clarity with TypedDict