Skip to content

Conversation

cbornet
Copy link
Collaborator

@cbornet cbornet commented Sep 3, 2025

No description provided.

Copy link

vercel bot commented Sep 3, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
langchain Ignored Ignored Preview Sep 10, 2025 8:06am

@cbornet cbornet force-pushed the langchain_v1-clean-ruff branch from d14e4fa to 59398e8 Compare September 3, 2025 22:18
Copy link

codspeed-hq bot commented Sep 3, 2025

CodSpeed WallTime Performance Report

Merging #32810 will not alter performance

Comparing cbornet:langchain_v1-clean-ruff (8df9205) with master (00e547c)

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

Copy link

codspeed-hq bot commented Sep 3, 2025

CodSpeed Instrumentation Performance Report

Merging #32810 will not alter performance

Comparing cbornet:langchain_v1-clean-ruff (8df9205) with master (00e547c)

Summary

✅ 14 untouched benchmarks

@cbornet cbornet force-pushed the langchain_v1-clean-ruff branch from 59398e8 to d64fe41 Compare September 3, 2025 22:27
@@ -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)
Copy link
Collaborator Author

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[
Copy link
Collaborator Author

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 ?

@cbornet cbornet force-pushed the langchain_v1-clean-ruff branch 8 times, most recently from 0982a5d to 2e4faa7 Compare September 4, 2025 12:53
@mdrxy mdrxy changed the title chore(langchain): cleanup langchain_v1 ruff config chore(langchain): cleanup langchain_v1 ruff config Sep 4, 2025
@mdrxy mdrxy added the linting Linting, formatting, or typing label Sep 4, 2025
@mdrxy mdrxy self-assigned this Sep 4, 2025
@mdrxy mdrxy added the langchain Related to the package `langchain` label Sep 4, 2025
@cbornet cbornet force-pushed the langchain_v1-clean-ruff branch 3 times, most recently from 94b4082 to 72ec713 Compare September 8, 2025 15:40

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)
Copy link
Collaborator Author

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",
Copy link
Collaborator Author

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 ?

@mdrxy mdrxy requested a review from Copilot September 8, 2025 21:23
Copy link
Contributor

@Copilot 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 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

@mdrxy
Copy link
Collaborator

mdrxy commented Sep 8, 2025

hmm

@cbornet cbornet force-pushed the langchain_v1-clean-ruff branch 3 times, most recently from 66cb167 to e131f7a Compare September 9, 2025 15:36
@cbornet cbornet force-pushed the langchain_v1-clean-ruff branch from e131f7a to a94ce8d Compare September 9, 2025 15:56
@cbornet cbornet force-pushed the langchain_v1-clean-ruff branch from a94ce8d to cf4161d Compare September 9, 2025 15:59
@@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the motivation?

Copy link
Collaborator Author

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.

@cbornet cbornet requested a review from mdrxy September 11, 2025 19:55
@cbornet
Copy link
Collaborator Author

cbornet commented Sep 11, 2025

@mdrxy I fixed the merge issues. Can you have a look ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
langchain Related to the package `langchain` linting Linting, formatting, or typing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants