-
Notifications
You must be signed in to change notification settings - Fork 19k
chore(langchain): cleanup langchain_v1
ruff config
#32810
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. |
d14e4fa
to
59398e8
Compare
CodSpeed WallTime Performance ReportMerging #32810 will not alter performanceComparing
|
CodSpeed Instrumentation Performance ReportMerging #32810 will not alter performanceComparing Summary
|
59398e8
to
d64fe41
Compare
@@ -221,7 +221,7 @@ def __init__( | |||
"Expected `model` to be a BaseChatModel or a string, got {type(model)}." | |||
"The `model` parameter should not have pre-bound tools, simply pass the model and tools separately." | |||
) | |||
raise ValueError(msg) | |||
raise TypeError(msg) |
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.
I guess it's still OK to do these breaking changes as it was not released yet ?
@@ -737,7 +737,7 @@ def _inject_store(self, tool_call: ToolCall, store: BaseStore | None) -> ToolCal | |||
def inject_tool_args( | |||
self, | |||
tool_call: ToolCall, | |||
input: Union[ | |||
input_: Union[ |
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.
I guess it's still OK to do these breaking changes as it was not released yet ?
0982a5d
to
2e4faa7
Compare
langchain_v1
ruff config
94b4082
to
72ec713
Compare
|
||
if not isinstance(request.model, ChatAnthropic): | ||
msg = ( | ||
"AnthropicPromptCachingMiddleware caching middleware only supports Anthropic models, " | ||
f"not instances of {type(request.model)}" | ||
) | ||
raise ValueError(msg) | ||
raise TypeError(msg) |
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.
I guess it's still OK to do these breaking changes as it was not released yet ?
@@ -13,45 +13,45 @@ class AnthropicPromptCachingMiddleware(AgentMiddleware): | |||
|
|||
def __init__( | |||
self, | |||
type: Literal["ephemeral"] = "ephemeral", | |||
cache_type: Literal["ephemeral"] = "ephemeral", |
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.
I guess it's still OK to do these breaking changes as it was not released yet ?
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 cleans up the ruff configuration for langchain_v1
by removing outdated per-file ignores and applying various linting fixes across the codebase. The changes include updating ruff version constraints, consolidating linting rules, and implementing hundreds of code quality improvements.
Key Changes:
- Simplified ruff configuration by removing complex per-file ignore patterns
- Updated code to comply with modern Python linting standards including proper import ordering, exception handling, and naming conventions
- Removed unused test utilities and improved type annotations throughout
Reviewed Changes
Copilot reviewed 29 out of 30 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
libs/langchain_v1/pyproject.toml | Updated ruff configuration with simplified rules and version constraints |
libs/langchain_v1/tests/unit_tests/stubs.py | Removed entire file containing unused test stub utilities |
libs/langchain_v1/tests/unit_tests/embeddings/test_caching.py | Added @OverRide decorators to MockEmbeddings methods |
libs/langchain_v1/tests/unit_tests/embeddings/test_base.py | Fixed regex pattern in pytest.raises assertion |
libs/langchain_v1/tests/unit_tests/chat_models/test_chat_models.py | Fixed regex pattern in pytest.raises assertion |
libs/langchain_v1/tests/unit_tests/agents/test_tool_node.py | Added periods to docstrings and improved exception handling |
libs/langchain_v1/tests/unit_tests/agents/test_return_direct_spec.py | Added keyword-only parameter to _make_tool function |
libs/langchain_v1/tests/unit_tests/agents/test_responses_spec.py | Renamed variable from InputModel to input_model for naming consistency |
libs/langchain_v1/tests/unit_tests/agents/test_responses.py | Replaced string equality checks with truthiness checks |
libs/langchain_v1/tests/unit_tests/agents/test_response_format.py | Improved import ordering and docstring formatting |
libs/langchain_v1/tests/unit_tests/agents/test_react_agent.py | Multiple improvements including variable naming, exception handling, and docstring formatting |
libs/langchain_v1/tests/unit_tests/agents/test_middleware_agent.py | Improved import ordering and exception handling patterns |
libs/langchain_v1/tests/unit_tests/agents/model.py | Added period to docstring |
libs/langchain_v1/tests/unit_tests/agents/messages.py | Added noqa comments for function naming conventions |
libs/langchain_v1/tests/unit_tests/agents/conftest.py | Changed tuple to set for membership testing |
libs/langchain_v1/tests/unit_tests/agents/any_str.py | Added slots definition to AnyStr class |
libs/langchain_v1/tests/integration_tests/chat_models/test_base.py | Renamed class from multiply to Multiply for proper naming |
libs/langchain_v1/tests/integration_tests/cache/fake_embeddings.py | Added @OverRide decorators to embedding methods |
libs/langchain_v1/scripts/check_imports.py | Improved docstring formatting |
libs/langchain_v1/langchain/chat_models/base.py | Added @OverRide decorators and improved string splitting logic |
libs/langchain_v1/langchain/agents/tool_node.py | Renamed parameter from input to input_ and improved exception handling |
libs/langchain_v1/langchain/agents/structured_output.py | Changed tuple to set for membership testing |
libs/langchain_v1/langchain/agents/react_agent.py | Improved variable naming and exception handling |
libs/langchain_v1/langchain/agents/middleware_agent.py | Improved exception chaining |
libs/langchain_v1/langchain/agents/middleware/summarization.py | Improved exception handling patterns |
libs/langchain_v1/langchain/agents/middleware/prompt_caching.py | Renamed parameter from type to cache_type and improved exception handling |
libs/langchain_v1/langchain/agents/interrupt.py | Reordered Union type arguments |
libs/langchain_v1/langchain/_internal/_prompts.py | Reordered Union type arguments |
libs/langchain_v1/langchain/init.py | Removed noqa comment for ANN401 rule |
hmm |
66cb167
to
e131f7a
Compare
e131f7a
to
a94ce8d
Compare
a94ce8d
to
cf4161d
Compare
@@ -122,9 +122,9 @@ def _get_prompt_runnable(prompt: Prompt | None) -> Runnable: | |||
lambda state: _get_state_value(state, "messages"), name=PROMPT_RUNNABLE_NAME | |||
) | |||
elif isinstance(prompt, str): | |||
_system_message: BaseMessage = SystemMessage(content=prompt) | |||
system_message: BaseMessage = SystemMessage(content=prompt) |
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.
what's the motivation?
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.
This is ruff rule RUF052
Was done by auto-fix.
@mdrxy I fixed the merge issues. Can you have a look ? |
No description provided.