(no title)
ozkatz | 7 months ago
class Person:
age: int
name: str
Would have to be boiled down to `dict[str, Any]` (or worse, `tuple[Any]`). You could use `typing.NamedTuple` without defining a class (`NamedTuple('Person', [('name', str), ('age', int)])`) - but subjectively, this is much less readable than simply using a data class.
Arch-TK|7 months ago
ozkatz|7 months ago
> There are typed dicts where you specify field names and the respective key types
The only way to achieve this that I'm aware of is PEP 589: subclassing TypedDict. Which I believe negates the argument in the post.
the__alchemist|7 months ago