Skip to content

Conversation

@cbornet
Copy link
Collaborator

@cbornet cbornet commented Jun 20, 2025

dict() is a problematic method name as it clashes with the builtin dict used as a type annotation.
This PR replaces it with an asdict method (inspired by dataclasses).
It also fixes a few places where dict must be replaced by builtins.dict until the dict() method is removed.

@vercel
Copy link

vercel bot commented Jun 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
langchain Ready Ready Preview Comment Sep 9, 2025 9:51am

@dosubot dosubot bot added the size:L label Jun 20, 2025
@cbornet cbornet requested a review from eyurtsev June 20, 2025 16:09
@dosubot dosubot bot added the 🤖:nit label Jun 20, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Jun 20, 2025

CodSpeed Performance Report

Merging #31685 will not alter performance

Comparing cbornet:typing-dict (5071da1) with master (880652b)1

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 13 untouched
⏩ 21 skipped2

Footnotes

  1. No successful run was found on master (9c21f83) during the generation of this report, so 880652b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 21 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@codspeed-hq
Copy link

codspeed-hq bot commented Jun 20, 2025

CodSpeed Instrumentation Performance Report

Merging #31685 will not alter performance

Comparing cbornet:typing-dict (92e60c5) with wip-v1.0 (188c015)

Summary

✅ 14 untouched benchmarks

@eyurtsev
Copy link
Collaborator

eyurtsev commented Jun 20, 2025

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 eyurtsev self-assigned this Jun 20, 2025
@cbornet cbornet changed the title core: deprecate problematic dict() method feat(core): deprecate problematic dict() method Jul 13, 2025
@cbornet
Copy link
Collaborator Author

cbornet commented Jul 22, 2025

@eyurtsev candidate for 1.0 ?

@mdrxy mdrxy added this to the v1 milestone Jul 22, 2025
@mdrxy mdrxy removed the 0.4 release label Jul 22, 2025
@mdrxy mdrxy added the core Related to the package `langchain-core` label Aug 7, 2025
@mdrxy mdrxy changed the base branch from master to wip-v0.4 August 7, 2025 18:28
@mdrxy mdrxy changed the title feat(core): deprecate problematic dict() method feat(core): deprecate problematic dict() method Aug 7, 2025
@mdrxy mdrxy requested a review from Copilot August 7, 2025 18:39
Copy link
Contributor

Copilot AI left a 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 for dict() across base classes
  • Adds deprecation decorators to existing dict() methods with migration guidance
  • Updates type annotations from dict to typing.Dict where 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

@mdrxy
Copy link
Member

mdrxy commented Aug 7, 2025

@cbornet please review

@cbornet
Copy link
Collaborator Author

cbornet commented Aug 12, 2025

@cbornet please review

done.

@mdrxy mdrxy changed the base branch from wip-v0.4 to wip-v1.0 August 25, 2025 18:25
@cbornet
Copy link
Collaborator Author

cbornet commented Aug 30, 2025

Something wrong happened with the change of git branch 😢

@cbornet cbornet requested a review from mdrxy August 31, 2025 20:01
@mdrxy mdrxy mentioned this pull request Aug 31, 2025
13 tasks
@eyurtsev eyurtsev added the v1 Issue specific to LangChain 1.0 label Sep 8, 2025
@github-actions github-actions bot added feature and removed core Related to the package `langchain-core` v1 Issue specific to LangChain 1.0 labels Oct 29, 2025
@cbornet cbornet changed the base branch from wip-v1.0 to master October 29, 2025 14:24
@github-actions github-actions bot added documentation Improvements or additions to documentation security core Related to the package `langchain-core` langchain Related to the package `langchain` infra Chores, devops, repo meta changes dependencies Pull requests that update a dependency file github_actions Pull requests that update GitHub Actions code cli Related to the package `langchain-cli` feature and removed feature documentation Improvements or additions to documentation infra Chores, devops, repo meta changes labels Oct 29, 2025
@cbornet
Copy link
Collaborator Author

cbornet commented Oct 29, 2025

Rebased on master now that v1 was released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to the package `langchain-cli` core Related to the package `langchain-core` dependencies Pull requests that update a dependency file feature github_actions Pull requests that update GitHub Actions code langchain Related to the package `langchain` security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants