Skip to content

Conversation

@mdrxy
Copy link
Member

@mdrxy mdrxy commented Dec 8, 2025

Adds PEP 702 __deprecated__ attribute support to the @deprecated decorator, enabling IDE and type checker integration for deprecation warnings.


PEP 702 introduced the __deprecated__ attribute convention, which type checkers (Pyright, mypy) and IDEs (VS Code with Pylance, PyCharm) can use to surface deprecations directly in the editor. This PR sets __deprecated__ on all objects decorated with @deprecated.

With this change, developers using supported IDEs will see:

  • Strikethrough text on deprecated symbols
  • Hover messages showing the deprecation reason and suggested alternative
  • Diagnostic warnings during type checking (e.g., pyright, mypy)

References

@mdrxy mdrxy requested a review from eyurtsev as a code owner December 8, 2025 19:49
@github-actions github-actions bot added core `langchain-core` package issues & PRs feature For PRs that implement a new feature; NOT A FEATURE REQUEST labels Dec 8, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 8, 2025

CodSpeed Performance Report

Merging #34257 will not alter performance

Comparing mdrxy/improve-deprecated (91dac71) with master (ed9bd6e)

⚠️ 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 skipped1

Footnotes

  1. 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.

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 adds PEP 702 __deprecated__ attribute support to the @deprecated decorator, enabling IDEs and type checkers (like Pyright and VS Code Pylance) to display deprecation warnings inline without requiring code execution. This improves the developer experience by showing strikethrough text and hover messages for deprecated APIs.

Key Changes:

  • Added _build_deprecation_message() helper function to generate PEP 702-compliant deprecation messages
  • Set __deprecated__ attribute on deprecated classes, properties, and functions/methods
  • Messages include alternative APIs when specified via alternative or alternative_import parameters

Comment on lines 347 to 351
# Set __deprecated__ for PEP 702 (IDE/type checker support)
prop.__deprecated__ = _build_deprecation_message( # type: ignore[attr-defined]
alternative=_alternative,
alternative_import=_alternative_import,
)
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as lines 247-251: _alternative and _alternative_import have been modified to include markdown backticks before being passed to _build_deprecation_message. Use the original alternative and alternative_import parameters instead.

Copilot uses AI. Check for mistakes.
eyurtsev
eyurtsev previously approved these changes Dec 9, 2025
@github-actions github-actions bot added feature For PRs that implement a new feature; NOT A FEATURE REQUEST and removed feature For PRs that implement a new feature; NOT A FEATURE REQUEST labels Dec 20, 2025
@mdrxy mdrxy merged commit 85c401f into master Dec 20, 2025
92 checks passed
@mdrxy mdrxy deleted the mdrxy/improve-deprecated branch December 20, 2025 03:07
@github-actions github-actions bot added feature For PRs that implement a new feature; NOT A FEATURE REQUEST and removed feature For PRs that implement a new feature; NOT A FEATURE REQUEST labels Dec 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core `langchain-core` package issues & PRs feature For PRs that implement a new feature; NOT A FEATURE REQUEST

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants