Giter VIP home page Giter VIP logo

Comments (4)

adriangb avatar adriangb commented on June 25, 2024 1

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.

ornariece avatar ornariece commented on June 25, 2024 1

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.

sydney-runkle avatar sydney-runkle commented on June 25, 2024

@ornariece,

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.

sydney-runkle avatar sydney-runkle commented on June 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.