GithubHelp home page GithubHelp logo

Comments (3)

oxan avatar oxan commented on May 13, 2024

There's a lot to unpack here.

The following two patches made it work. I think the first one is a bug as it detects wrongly int | str | None as an Optional[int].

That's indeed not correct, though I don't think your patch is a good solution. int | str | None actually is an optional type (optional really just means nullable), but it should be Optional[int | str], not Optional[int].

The second patch allows mapping UnionType aliases to Field serializers but does not support overriding other kinds of aliases.

This part looks correct to me.

In this case, the library calls lookup_type_in_mapping using JsonPrimitive rather than JsonKV. To be honest, I don't know which is the best approach to solve this or even if this should be supported. It makes sense for our dynamic serializers though.

I agree it's not a bad idea to support this, though I'm also not immediately sure of the best way to support this.

from djangorestframework-dataclasses.

oxan avatar oxan commented on May 13, 2024

The following two patches made it work. I think the first one is a bug as it detects wrongly int | str | None as an Optional[int].

That's indeed not correct, though I don't think your patch is a good solution. int | str | None actually is an optional type (optional really just means nullable), but it should be Optional[int | str], not Optional[int].

This has been fixed in e26c57a (and follow-up bc8d79a).

The second patch allows mapping UnionType aliases to Field serializers but does not support overriding other kinds of aliases.

This part looks correct to me.

This has been fixed in be6359b (I forgot to credit you, sorry about that).

I'll leave this issue open for your last point, though I'm not sure right now if and how that can be fixed.

from djangorestframework-dataclasses.

emarbo avatar emarbo commented on May 13, 2024

Hi @oxan,

Thank you for taking the time to respond and fix that bugs!!! I very much appreciate it. And, my apologies for putting so much stuff in a single issue; these were unrelated things.

Regarding the last point, we can leave this as it is. If we reencounter this problem, we'll try to solve it ourselves and then post some proposal here. And no worries about the credit; not needed at all, we are happy just helping a bit.

from djangorestframework-dataclasses.

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.