3 ms·
I'm sure that the pydantic guys had a reason to rename .dict to .model_dump. This single change caused so much grieve when upgrading to pydantic2.1 The very ide
by gostsamo 1y ago
I'm sure that the pydantic guys had a reason to rename .dict to .model_dump. This single change caused so much grieve when upgrading to pydantic2.1 The very idea of unnecessary breaking changes is a big reason not to over rely on pydantic, tbh.
1 we were using .dict to introduce pydantic in the mix of other entity schemes and handling this change later was a significant pain in the neck. Some python introspection mechanism that can facilitate deep object recasting might've been nice if possible.
- jmogly 1y agoHaha, ChatGPT recommends this: from pydantic import BaseModel class MyModel(BaseModel): name: str def dict(self, *args, **kwargs): return self.model_dump(*args, **kwargs)
- gostsamo 1y agoYep, and when you are done migrating, you need to remove this, and there is pydantic3 coming. Keeping in mind the number of libraries nad microservices involved, search and replace was the easier option. PS: thank you, I can think on my own and even failing that, chat gpt is not in closed beta any more.
- the__alchemist 1y agoRepresenting structured data as key/value pairs is a pattern I've only seen in Python, and don't understand why it became popular and canonical.
- halfcat 1y ago> Representing structured data as key/value pairs is a pattern I've only seen in Python Come on. We know you’ve seen JavaScript.