Comments (4)
At first glance I don't think it's a bug per se but maybe more like a limitation of what you can achieve with these annotations.
from pydantic.
Looks like the current behavior is such that the custom get schema function overrides any changes applied via annotations.
you got that backwards: the annotation is overriding the custom serializer of the type.
From an implementation point-of-view, I get why you'd think this is more a limitation than a bug, since the workaround for a user is pretty straightforward. However, I'd definitely argue that this is conceptually a bug. Also, it can be very disorientating for a user using a custom type from a 3rd-party library: here the user would likely not be aware beforehand that the custom type is using a custom serializer method, and would annotate it all the same in their code, at which point they would be confused as to why their WrapSerializer
doesn't actually wrap the expected serialization.
from pydantic.
Hmm, thanks for reporting this. I don't think this is necessarily a bug, but perhaps a change request. Looks like the current behavior is such that the custom get schema function overrides any changes applied via annotations.
@adriangb, is this intentional? Is this something we want to change?
from pydantic.
you got that backwards: the annotation is overriding the custom serializer of the type.
Ah yes, you're right. This seems like a bug!
from pydantic.
Related Issues (20)
- Field deprecation with typing_extension.deprecated example in `doc>concepts/fields` does not work HOT 2
- validate_assignment = True & @model_validator(mode='after') crashes HOT 1
- No package metadata was found for email-validator HOT 3
- mypy plugin reports unsafe variance error on frozen models HOT 2
- mypy plugin reports an unsafe variance error with no line number when extending class where the error is suppressed HOT 3
- Model validator is ignored during inheritance HOT 3
- When using model_validator in mode=before in a child A of pydantic class, this affects also other children. HOT 1
- Discriminated Union: wrong type is chosen for serialization HOT 2
- use SkipValidation not working with orm @property Decorator HOT 6
- HttpUrl doesn't require TLD HOT 2
- Drop support for pytest 7.4 HOT 2
- Frequent occurrence of attributes without errors HOT 3
- __pydantic_extra__ value validators passed entire dict HOT 11
- Pydantic 1.X doesn't work with Python 3.12.4 HOT 5
- TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard' HOT 4
- CPython 3.13 warns on FutureRef._evaluate/typing._eval_type not passing `type_params` HOT 5
- Constant value in a Pydantic V2 field does not allow an object value HOT 1
- `typing.Unpack` support: Unpack typed dict for keyword argument typing HOT 2
- unlucky md5 checksum value is parsed to inf HOT 5
- Python 3.12 support in 1.10.x? HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pydantic.