Giter Site home page Giter Site logo

Comments (4)

Kludex avatar Kludex commented on August 27, 2024 1

Got an idea!

I'm going to do the transformation, and add a TODO note.

This:

class Foo(BaseModel):
   class Config:
         getter_dict = SomeClass  # getter_dict is no longer present in pydantic v2

To:

class Foo(BaseModel):
   # TODO: The `getter_dict` was removed, please check LINK.
   model_config = ConfigDict(getter_dict=SomeClass)

from bump-pydantic.

Kludex avatar Kludex commented on August 27, 2024

We have some options for that specific case. Let's see which one is the best:

  1. Don't check removed attributes from Config. Runtime will fail.
  2. Don't refactor that class, and raise a warning.
  3. Refactor that class, and raise a warning.

Unless I'm forgetting something, those should be the available options.

Option 1 I think is out of question, but it's what is currently implemented, since there's no logic to verify removed fields.

As for 2, and 3, I guess 3 would be easier for the user, because 2 implies the user will have to do all manual changes.

from bump-pydantic.

lig avatar lig commented on August 27, 2024

Adding a TODO seems like a nice touch

from bump-pydantic.

Kludex avatar Kludex commented on August 27, 2024

The decision here:

  1. Only Config classes with assignments are converted to model_config. If there's any other structure like functions, or classes inside, then a note is added mentioning that the user should manually replace it (with a link to the migration docs).
  2. If the keyword got removed, a specific note is added, informing about the removal. In this case, the model_config replaces the Config.

I'll close this because I think I've addressed the question, but feedbacks are welcome.

from bump-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.