-
Notifications
You must be signed in to change notification settings - Fork 17.3k
core: Cleanup Pydantic models and handle deprecation warnings #30799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
cbornet
commented
Apr 12, 2025
•
edited
Loading
edited
- Simplified Pydantic handling since Pydantic v1 is not supported anymore.
- Replace use of deprecated v1 methods by corresponding v2 methods.
- Remove use of other deprecated methods.
- Activate mypy errors on deprecated methods use.
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
7529366
to
5fcb2bb
Compare
14905a4
to
6b9bb2c
Compare
@@ -183,6 +122,9 @@ def pre_init(func: Callable) -> Any: | |||
with warnings.catch_warnings(): | |||
warnings.filterwarnings(action="ignore", category=PydanticDeprecationWarning) | |||
|
|||
# Ideally we would use @model_validator(mode="before") but this would change the | |||
# order of the validators. See https://github.com/pydantic/pydantic/discussions/7434. | |||
# So we keep root_validator for backward compatibility. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One possibility would be to deprecate pre_init
and create a new decorator, for instance before_init
, that uses model_validator
.
WDYT ?
6b9bb2c
to
d4b2366
Compare
I would love to drop v1 support (would clean up the codebase a lot). Need to chat with the team about this depending on download #s, etc. |
Note: LangChain already dropped support for Pydantic v1. There remains some models using |
d4b2366
to
3c2f2ba
Compare