Conversation
|
Typing can be quite tricky. I’d be grateful if anyone could improve the type hints in converters.pyi. :-) |
|
Heh, I'm just finishing up a blog post about how attrs+cattrs is better than Pydantic since these kinds of type-altering converters don't belong on the models themselves. A small taste of the post: what if you want two code paths for converting datetimes, one for ISO 8601 and one for the unix timestamps? Also paying the price for those code paths in your code (i.e. when not loading from json or whatever) is silly. Well, at least in attrs they would be opt-in if we merge this, instead of just there forever like in Pydantic (I'm aware of Pydantic ORM mode). |
|
Yes, I see your point. But these converters (and maybe eventually the auto-convert hook) are purely optional and make writing simple API clients or loading data from JSON a lot easier. And you don't need to install the additional cattr packages for these simple cases. |
|
Closing this in favor of #830 |
See: #813
Pull Request Check List
This is just a friendly reminder about the most common mistakes. Please make sure that you tick all boxes. But please read our contribution guide at least once, it will save you unnecessary review cycles!
If an item doesn't apply to your pull request, check it anyway to make it apparent that there's nothing left to do. If your pull request is a documentation fix or a trivial typo, feel free to delete the whole thing.
.pyi).tests/typing_example.py.docs/api.rstby hand.@attr.s()have to be added by hand too.versionadded,versionchanged, ordeprecateddirectives. Find the appropriate next version in our__init__.pyfile..rstfiles is written using semantic newlines.changelog.d.If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!