Comments (4)
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.
We have some options for that specific case. Let's see which one is the best:
- Don't check removed attributes from Config. Runtime will fail.
- Don't refactor that class, and raise a warning.
- 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.
Adding a TODO seems like a nice touch
from bump-pydantic.
The decision here:
- Only
Config
classes with assignments are converted tomodel_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). - If the keyword got removed, a specific note is added, informing about the removal. In this case, the
model_config
replaces theConfig
.
I'll close this because I think I've addressed the question, but feedbacks are welcome.
from bump-pydantic.
Related Issues (20)
- RecursionError when processing file with a large number of enums HOT 1
- Field(example=...) needs a codemod. HOT 1
- BP008: Not Handling conint(ge= , lt=) Correctly HOT 1
- Literal values "and" and "or" cause ParserSyntaxError HOT 10
- env -> validation_alias? HOT 1
- License info missing in classifiers and/or meta data HOT 3
- On Windows machines with >= 32 cores (more than 64 logical processors) execution fails HOT 1
- @root_validator will not updated to model_validator HOT 1
- [BUG]: bumb-pydantic doesnt change files HOT 2
- Set libcst dependency version HOT 1
- Rule BP002: Replace Config class by model_config attribute does not keep the arbitrary_types_allowed argument value
- uncovered case in validator->field_validator
- Issue with Literal["$"] being converted HOT 2
- Ignore .tox files HOT 2
- Add support for handling unannotated fields
- Examples in codemod files do not all work HOT 1
- Log.txt file automatic creation in PWD is kind of an anti-feature HOT 3
- Not Transformed automatically for other parent class except BaseModel HOT 2
- I have a big pile of improvements to upstream HOT 2
- BP008 may not be working as intended. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bump-pydantic.