-
Notifications
You must be signed in to change notification settings - Fork 19.8k
feat(core): deprecate problematic dict() method
#31685
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
CodSpeed Performance ReportMerging #31685 will not alter performanceComparing
|
CodSpeed Instrumentation Performance ReportMerging #31685 will not alter performanceComparing Summary
|
|
We could merge as part of the 0.4 release. Unclear yet whether this change should be made -- better not to clash with a built in for new code, but for existing code this would be weighed from a cost benefit analysis to end users |
|
@eyurtsev candidate for 1.0 ? |
dict() method
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.
Pull Request Overview
This PR deprecates the problematic dict() method that clashes with Python's builtin dict type annotation and replaces it with an asdict() method inspired by dataclasses. The change addresses type annotation conflicts by introducing proper deprecation warnings and updating internal usage.
Key changes:
- Introduces
asdict()method as replacement fordict()across base classes - Adds deprecation decorators to existing
dict()methods with migration guidance - Updates type annotations from
dicttotyping.Dictwhere the builtin conflicts with the method name
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
libs/core/langchain_core/prompts/base.py |
Adds asdict() method, deprecates dict(), updates type annotations and internal usage |
libs/core/langchain_core/output_parsers/base.py |
Adds asdict() method and deprecates dict() with proper decorator |
libs/core/langchain_core/language_models/llms.py |
Updates type annotations, adds asdict() method, and replaces internal dict() calls |
libs/core/langchain_core/language_models/chat_models.py |
Updates type annotations, adds asdict() method, and replaces internal usage |
|
@cbornet please review |
0018be9 to
82a3f22
Compare
done. |
|
Something wrong happened with the change of git branch 😢 |
|
Rebased on master now that v1 was released. |
dict()is a problematic method name as it clashes with the builtindictused as a type annotation.This PR replaces it with an
asdictmethod (inspired by dataclasses).It also fixes a few places where
dictmust be replaced bybuiltins.dictuntil thedict()method is removed.