3 ms·
IMO A better fix is to use http://attrs.org http://attrs.org or dataclasses to replace the dicts entirely.
by j88439h84 7y ago
IMO A better fix is to use http://attrs.org http://attrs.org or dataclasses to replace the dicts entirely.
- deleted 7y ago[deleted]
- emddudley 7y agoAgreed--if you're going to go through the trouble of adding detailed type hints to describe a dict, you're like 90% of the way to a dataclass with better usability.
- ben509 7y agoAnd then use a library like json-syntax[1] to translate those into JSON. [1]: https://pypi.org/project/json-syntax/ https://pypi.org/project/json-syntax/
- ledauphin 7y agothis looks interesting. we use cattrs, which has worked well for us but has a long-delayed 1.0 release.
- hermitdev 7y agoOne of the features I'm looking forward to using is the kwdargs support in dataclasses. Honestly, find it so much more useful and intuitive than the 3.7 positional only.