3 ms·
The article doesn't mention my train for loving TypedDict. I worked on a python app built by a man with a stronger will to succeed than ability to code. Data
by psd1 2y ago
The article doesn't mention my train for loving TypedDict.
I worked on a python app built by a man with a stronger will to succeed than ability to code.
Data was passed as dicts. Many methods (in the god object, natch) destructured, unwrapped or mutated before passing the new dict to some other method.
TypedDict allowed me to annotate these shitty dicts. It became possible to reason about the code without spending two hours tracing code paths.
The real solution is to be better at code. But, given an app written by a dict fetishist, it's a pretty good solution.
- sevensor 2y agoI’ve been in the same boat. The amount of pain you can reduce by pushing type annotations through a codebase like that is spectacular. And although I love dataclasses, the non-totality that you get from typeddicts is key for modeling the kind of mess you describe.
- psd1 2y agoTypedDict is a drop-in solution. Dataclasses is a big scary refactor. I'd use dataclasses in a new app, but it was not really an option in that app.