Code Monkey home page Code Monkey logo

Comments (7)

abondar avatar abondar commented on September 22, 2024 3

Yeah, fixed with pydantic 2.7.1

from tortoise-orm.

abondar avatar abondar commented on September 22, 2024 2

Sounds good, right now I am working on some clean up and rooting out one elusive bug, when I will be ready to make release I'll try to incorporate this extra

from tortoise-orm.

0xdbff avatar 0xdbff commented on September 22, 2024 1

Examples from the website are failing with pydantic 2.7, maybe this should be documented?

from tortoise-orm.

abondar avatar abondar commented on September 22, 2024 1

They confirmed that it is indeed pydantic bug, which will be fixed in 2.7.1, which should be released today

I'll close issue once I confirm that fix works

from tortoise-orm.

tan-wood avatar tan-wood commented on September 22, 2024

Has anyone found any work arounds in the mean time?

from tortoise-orm.

abondar avatar abondar commented on September 22, 2024

Yeah, I can confirm that bug is real

Problem seems to be that something changed in processing of models in pydantic, and it recognises Model.Meta as attribute and sends it to validation, which fails, because models generated by pydantic_model_creator has extra="forbid", not allowing extra attributes.

As very hacky workaround - you can run

from tortoise.contrib.pydantic import PydanticModel

PydanticModel.model_config["extra"] = "ignore"

somewhere on init of your code, before pydantic_model_creator

I also created issue with pydantic - pydantic/pydantic#9300 - may be they will be able to provide some insights into why this is happening and how can we bypass that without switching from extra="forbid"

from tortoise-orm.

jamesbraza avatar jamesbraza commented on September 22, 2024

Thanks for making that issue @abondar and ensuring the community is back up and running. What do you think of:

  • Making a pip extra for Pydantic in Tortoise
  • And excluding Pydantic 2.7.0 from the extra

So taking this https://github.com/tortoise/tortoise-orm/blob/0.20.0/pyproject.toml#L75 to something like pydantic = "^2.0,!=2.7.0"

from tortoise-orm.

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.