Giter VIP home page Giter VIP logo

Comments (2)

kpodp0ra avatar kpodp0ra commented on May 26, 2024 1

Confirm that #191 fixes all my codebase.

from mashumaro.

Fatal1ty avatar Fatal1ty commented on May 26, 2024

@kpodp0ra

Hi, thank you for opening this issue.

TypedDicts are not working with from future import annotations.

I managed to add support for ForwardRef in JSON Schema generation here, so your example will work as expected now.

Also, it's worth noting that adding this line on top of tests/test_jsonschema/test_jsonschema_generation.py breaks tests:

  • test_jsonschema_for_named_tuple_with_overridden_serialization_method
  • test_jsonschema_for_typeddict
  • test_overridden_serialization_method_with_return_annotation
  • test_dataclass_overridden_serialization_method
  • test_third_party_overridden_serialization_method

Thank you for pointing out. This is due to restrictions in PEP 563 implementation:

Annotations can only use names present in the module scope as postponed evaluation using local names is not reliable (with the sole exception of class-level names resolved by typing.get_type_hints()).

So, as long as you don't define the data types inside the function, everything will be fine. We could try to hack it by juggling f_locals of frame objects to support forward refs to local types, but I just don't see much need for it right now. In some cases it will work without hacks, but in others it won't. Do you need JSON Schema for local types?

from mashumaro.

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.