-
Notifications
You must be signed in to change notification settings - Fork 19.6k
chore(core): add ruff rule PLR2004
#33706
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
Conversation
CodSpeed Performance ReportMerging #33706 will not alter performanceComparing
|
PLR2004
Co-authored-by: Mason Daugherty <[email protected]>
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 removes the ruff linting rule PLR2004 (comparison to magic numbers) from the global ignore list and replaces hardcoded numeric literals throughout the codebase with named constants to improve code readability and maintainability.
- Extracted magic numbers into descriptive named constants across multiple files
- Improved error handling for tuple unpacking operations with better exception chaining
- Hardcoded Pydantic version flags to v2 only
- Fixed minor issues in error message formatting and conditional logic
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| libs/core/pyproject.toml | Enabled PLR2004 rule globally, kept disabled for tests |
| libs/core/langchain_core/utils/pydantic.py | Hardcoded Pydantic version flags to v2 values |
| libs/core/langchain_core/utils/function_calling.py | Replaced magic number 2 with named constant _MIN_DOCSTRING_BLOCKS |
| libs/core/langchain_core/tools/base.py | Improved tuple unpacking error handling and updated error message |
| libs/core/langchain_core/runnables/graph_mermaid.py | Replaced magic number 500 with requests.codes.internal_server_error |
| libs/core/langchain_core/runnables/branch.py | Replaced magic number 2 with named constant _MIN_BRANCHES |
| libs/core/langchain_core/runnables/base.py | Replaced multiple magic numbers with named constants |
| libs/core/langchain_core/prompts/chat.py | Improved tuple unpacking validation with better error handling |
| libs/core/langchain_core/messages/utils.py | Improved tuple unpacking with try-except pattern |
| libs/core/langchain_core/language_models/chat_models.py | Replaced magic number 100 with named constant _MAX_CLEANUP_DEPTH |
No description provided.