Skip to content

The agent engineering platform.

chore(core): fix some ruff preview rules (#34425)

Christophe Bornet72f1d7902293
diff --git a/libs/core/langchain_core/example_selectors/length_based.py b/libs/core/langchain_core/example_selectors/length_based.py
index 9424e645bf..aaa7291305 100644
--- a/libs/core/langchain_core/example_selectors/length_based.py
+++ b/libs/core/langchain_core/example_selectors/length_based.py
@@ -11,7 +11,7 @@ from langchain_core.prompts.prompt import PromptTemplate
def _get_length_based(text: str) -> int:
- return len(re.split("\n| ", text))
+ return len(re.split(r"\n| ", text))
class LengthBasedExampleSelector(BaseExampleSelector, BaseModel):
diff --git a/libs/core/langchain_core/language_models/chat_models.py b/libs/core/langchain_core/language_models/chat_models.py
index 911556722f..86f9222e77 100644
--- a/libs/core/langchain_core/language_models/chat_models.py
+++ b/libs/core/langchain_core/language_models/chat_models.py
@@ -547,7 +547,7 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
):
if block["type"] != index_type:
index_type = block["type"]
- index = index + 1
+ index += 1
if "index" not in block:
block["index"] = index
run_manager.on_llm_new_token(
@@ -679,7 +679,7 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
):
if block["type"] != index_type:
index_type = block["type"]
- index = index + 1
+ index += 1
if "index" not in block:
block["index"] = index
await run_manager.on_llm_new_token(
@@ -730,7 +730,7 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
# --- Custom methods ---
- def _combine_llm_outputs(self, llm_outputs: list[dict | None]) -> dict: # noqa: ARG002
+ def _combine_llm_outputs(self, _llm_outputs: list[dict | None], /) -> dict:
return {}
def _convert_cached_generations(self, cache_val: list) -> list[ChatGeneration]:
@@ -1187,7 +1187,7 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
):
if block["type"] != index_type:
index_type = block["type"]
- index = index + 1
+ index += 1
if "index" not in block:
block["index"] = index
if run_manager:
@@ -1305,7 +1305,7 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
):
if block["type"] != index_type:
index_type = block["type"]
- index = index + 1
+ index += 1
if "index" not in block:
block["index"] = index
if run_manager:
diff --git a/libs/core/langchain_core/messages/ai.py b/libs/core/langchain_core/messages/ai.py
index 30ce46699e..bf23d7a12e 100644
--- a/libs/core/langchain_core/messages/ai.py
+++ b/libs/core/langchain_core/messages/ai.py
@@ -326,7 +326,7 @@ class AIMessage(BaseMessage):
if tool_calls := values.get("tool_calls"):
values["tool_calls"] = [
create_tool_call(
- **{k: v for k, v in tc.items() if k not in ("type", "extras")}
+ **{k: v for k, v in tc.items() if k not in {"type", "extras"}}
)
for tc in tool_calls
]
@@ -442,7 +442,7 @@ class AIMessageChunk(AIMessage, BaseMessageChunk):
blocks = [
block
for block in blocks
- if block["type"] not in ("tool_call", "invalid_tool_call")
+ if block["type"] not in {"tool_call", "invalid_tool_call"}
]
for tool_call_chunk in self.tool_call_chunks:
tc: types.ToolCallChunk = {
@@ -573,7 +573,7 @@ class AIMessageChunk(AIMessage, BaseMessageChunk):
if (
isinstance(block, dict)
and block.get("type")
- in ("server_tool_call", "server_tool_call_chunk")
+ in {"server_tool_call", "server_tool_call_chunk"}
and (args_str := block.get("args"))
and isinstance(args_str, str)
):
diff --git a/libs/core/langchain_core/messages/block_translators/anthropic.py b/libs/core/langchain_core/messages/block_translators/anthropic.py
index 86ad0226d1..a02658856d 100644
--- a/libs/core/langchain_core/messages/block_translators/anthropic.py
+++ b/libs/core/langchain_core/messages/block_translators/anthropic.py
@@ -159,12 +159,12 @@ def _convert_citation_to_v1(citation: dict[str, Any]) -> types.Annotation:
return url_citation
- if citation_type in (
+ if citation_type in {
"char_location",
"content_block_location",
"page_location",
"search_result_location",
- ):
+ }:
document_citation: types.Citation = {
"type": "citation",
"cited_text": citation["cited_text"],
@@ -173,8 +173,6 @@ def _convert_citation_to_v1(citation: dict[str, Any]) -> types.Annotation:
document_citation["title"] = citation["document_title"]
elif title := citation.get("title"):
document_citation["title"] = title
- else:
- pass
known_fields = {
"type",
"cited_text",
@@ -280,8 +278,6 @@ def _convert_to_v1_from_anthropic(message: AIMessage) -> list[types.ContentBlock
"id": tc.get("id"),
}
break
- else:
- pass
if not tool_call_block:
tool_call_block = {
"type": "tool_call",
diff --git a/libs/core/langchain_core/messages/block_translators/bedrock_converse.py b/libs/core/langchain_core/messages/block_translators/bedrock_converse.py
index e6f9ae876d..dfb38b9037 100644
--- a/libs/core/langchain_core/messages/block_translators/bedrock_converse.py
+++ b/libs/core/langchain_core/messages/block_translators/bedrock_converse.py
@@ -240,8 +240,6 @@ def _convert_to_v1_from_converse(message: AIMessage) -> list[types.ContentBlock]
"id": tc.get("id"),
}
break
- else:
- pass
if not tool_call_block:
tool_call_block = {
"type": "tool_call",
diff --git a/libs/core/langchain_core/messages/block_translators/google_genai.py b/libs/core/langchain_core/messages/block_translators/google_genai.py
index da51ed74f6..901538dc5d 100644
--- a/libs/core/langchain_core/messages/block_translators/google_genai.py
+++ b/libs/core/langchain_core/messages/block_translators/google_genai.py
@@ -411,7 +411,10 @@ def _convert_to_v1_from_genai(message: AIMessage) -> list[types.ContentBlock]:
except Exception:
# Not valid base64, treat as non-standard
converted_blocks.append(
- {"type": "non_standard", "value": item}
+ {
+ "type": "non_standard",
+ "value": item,
+ }
)
else:
# This likely won't be reached according to previous implementations
diff --git a/libs/core/langchain_core/messages/block_translators/openai.py b/libs/core/langchain_core/messages/block_translators/openai.py
index 875fee78ff..a3d4234dfd 100644
--- a/libs/core/langchain_core/messages/block_translators/openai.py
+++ b/libs/core/langchain_core/messages/block_translators/openai.py
@@ -271,7 +271,7 @@ def _convert_from_v1_to_chat_completions(message: AIMessage) -> AIMessage:
if block_type == "text":
# Strip annotations
new_content.append({"type": "text", "text": block["text"]})
- elif block_type in ("reasoning", "tool_call"):
+ elif block_type in {"reasoning", "tool_call"}:
pass
else:
new_content.append(block)
@@ -729,8 +729,6 @@ def _convert_to_v1_from_responses(message: AIMessage) -> list[types.ContentBlock
if invalid_tool_call.get("id") == call_id:
tool_call_block = invalid_tool_call.copy()
break
- else:
- pass
if tool_call_block:
if "id" in block:
if "extras" not in tool_call_block:
@@ -758,7 +756,7 @@ def _convert_to_v1_from_responses(message: AIMessage) -> list[types.ContentBlock
k: v for k, v in block["action"].items() if k != "sources"
}
for key in block:
- if key not in ("type", "id", "action", "status", "index"):
+ if key not in {"type", "id", "action", "status", "index"}:
web_search_call[key] = block[key]
yield cast("types.ServerToolCall", web_search_call)
@@ -784,8 +782,6 @@ def _convert_to_v1_from_responses(message: AIMessage) -> list[types.ContentBlock
web_search_result["status"] = "success"
elif status:
web_search_result["extras"] = {"status": status}
- else:
- pass
if "index" in block and isinstance(block["index"], int):
web_search_result["index"] = f"lc_wsr_{block['index'] + 1}"
yield cast("types.ServerToolResult", web_search_result)
@@ -801,14 +797,14 @@ def _convert_to_v1_from_responses(message: AIMessage) -> list[types.ContentBlock
file_search_call["index"] = f"lc_fsc_{block['index']}"
for key in block:
- if key not in (
+ if key not in {
"type",
"id",
"queries",
"results",
"status",
"index",
- ):
+ }:
file_search_call[key] = block[key]
yield cast("types.ServerToolCall", file_search_call)
@@ -827,8 +823,6 @@ def _convert_to_v1_from_responses(message: AIMessage) -> list[types.ContentBlock
file_search_result["status"] = "success"
elif status:
file_search_result["extras"] = {"status": status}
- else:
- pass
if "index" in block and isinstance(block["index"], int):
file_search_result["index"] = f"lc_fsr_{block['index'] + 1}"
yield cast("types.ServerToolResult", file_search_result)
@@ -872,8 +866,6 @@ def _convert_to_v1_from_responses(message: AIMessage) -> list[types.ContentBlock
code_interpreter_result["status"] = "success"
elif status:
code_interpreter_result["extras"] = {"status": status}
- else:
- pass
if "index" in block and isinstance(block["index"], int):
code_interpreter_result["index"] = f"lc_cir_{block['index'] + 1}"
diff --git a/libs/core/langchain_core/messages/utils.py b/libs/core/langchain_core/messages/utils.py
index 6ea7b53b04..eaa04bf1af 100644
--- a/libs/core/langchain_core/messages/utils.py
+++ b/libs/core/langchain_core/messages/utils.py
@@ -1432,7 +1432,7 @@ def convert_to_openai_messages(
}
)
elif (
- block.get("type") in ["thinking", "reasoning"]
+ block.get("type") in {"thinking", "reasoning"}
or pass_through_unknown_blocks
):
content.append(block)
diff --git a/libs/core/langchain_core/runnables/graph_png.py b/libs/core/langchain_core/runnables/graph_png.py
index 2921120142..737f9445d9 100644
--- a/libs/core/langchain_core/runnables/graph_png.py
+++ b/libs/core/langchain_core/runnables/graph_png.py
@@ -201,7 +201,8 @@ class PngDrawer:
viz, start, end, str(data) if data is not None else None, cond
)
- def update_styles(self, viz: Any, graph: Graph) -> None:
+ @staticmethod
+ def update_styles(viz: Any, graph: Graph) -> None:
"""Update the styles of the entrypoint and END nodes.
Args:
diff --git a/libs/core/langchain_core/tools/base.py b/libs/core/langchain_core/tools/base.py
index 94f9e10e5a..c4fd234e48 100644
--- a/libs/core/langchain_core/tools/base.py
+++ b/libs/core/langchain_core/tools/base.py
@@ -95,7 +95,7 @@ def _is_annotated_type(typ: type[Any]) -> bool:
Returns:
`True` if the type is an Annotated type, `False` otherwise.
"""
- return get_origin(typ) in (typing.Annotated, typing_extensions.Annotated)
+ return get_origin(typ) in {typing.Annotated, typing_extensions.Annotated}
def _get_annotation_description(arg_type: type) -> str | None:
diff --git a/libs/core/langchain_core/tracers/evaluation.py b/libs/core/langchain_core/tracers/evaluation.py
index 7744c229ca..16a3e94cd1 100644
--- a/libs/core/langchain_core/tracers/evaluation.py
+++ b/libs/core/langchain_core/tracers/evaluation.py
@@ -154,8 +154,8 @@ class EvaluatorCallbackHandler(BaseTracer):
res
)
+ @staticmethod
def _select_eval_results(
- self,
results: EvaluationResult | EvaluationResults,
) -> list[EvaluationResult]:
if isinstance(results, EvaluationResult):
diff --git a/libs/core/langchain_core/tracers/langchain.py b/libs/core/langchain_core/tracers/langchain.py
index 9fb974ced6..6e352f1327 100644
--- a/libs/core/langchain_core/tracers/langchain.py
+++ b/libs/core/langchain_core/tracers/langchain.py
@@ -247,7 +247,8 @@ class LangChainTracer(BaseTracer):
log_error_once("post", e)
raise
- def _update_run_single(self, run: Run) -> None:
+ @staticmethod
+ def _update_run_single(run: Run) -> None:
"""Update a run."""
if run.extra.get("__disabled"):
return
diff --git a/libs/core/langchain_core/utils/_merge.py b/libs/core/langchain_core/utils/_merge.py
index 2559c09015..d37f8fd48a 100644
--- a/libs/core/langchain_core/utils/_merge.py
+++ b/libs/core/langchain_core/utils/_merge.py
@@ -58,7 +58,7 @@ def merge_dicts(left: dict[str, Any], *others: dict[str, Any]) -> dict[str, Any]
# "all dicts."
# )
if (right_k == "index" and merged[right_k].startswith("lc_")) or (
- right_k in ("id", "output_version", "model_provider")
+ right_k in {"id", "output_version", "model_provider"}
and merged[right_k] == right_v
):
continue
diff --git a/libs/core/langchain_core/utils/aiter.py b/libs/core/langchain_core/utils/aiter.py
index e773cb899c..e00dc99a92 100644
--- a/libs/core/langchain_core/utils/aiter.py
+++ b/libs/core/langchain_core/utils/aiter.py
@@ -130,7 +130,7 @@ async def tee_peer(
if buffer:
continue
try:
- item = await iterator.__anext__()
+ item = await anext(iterator)
except StopAsyncIteration:
break
else:
diff --git a/libs/core/langchain_core/utils/function_calling.py b/libs/core/langchain_core/utils/function_calling.py
index 32c20dc85d..6f8e46a23f 100644
--- a/libs/core/langchain_core/utils/function_calling.py
+++ b/libs/core/langchain_core/utils/function_calling.py
@@ -247,7 +247,7 @@ def _convert_any_typed_dicts_to_pydantic(
)
fields: dict = {}
for arg, arg_type in annotations_.items():
- if get_origin(arg_type) in (Annotated, typing_extensions.Annotated):
+ if get_origin(arg_type) in {Annotated, typing_extensions.Annotated}:
annotated_args = get_args(arg_type)
new_arg_type = _convert_any_typed_dicts_to_pydantic(
annotated_args[0], depth=depth + 1, visited=visited
diff --git a/libs/core/langchain_core/utils/mustache.py b/libs/core/langchain_core/utils/mustache.py
index 1df4ace37b..8134355a50 100644
--- a/libs/core/langchain_core/utils/mustache.py
+++ b/libs/core/langchain_core/utils/mustache.py
@@ -85,7 +85,7 @@ def l_sa_check(
# If all the characters since the last newline are spaces
# Then the next tag could be a standalone
# Otherwise it can't be
- return padding.isspace() or padding == ""
+ return padding.isspace() or not padding
return False
@@ -305,7 +305,7 @@ def tokenize(
# Start yielding
# Ignore literals that are empty
- if literal != "":
+ if literal:
yield ("literal", literal)
# Ignore comments and set delimiters
diff --git a/libs/core/tests/unit_tests/language_models/chat_models/test_base.py b/libs/core/tests/unit_tests/language_models/chat_models/test_base.py
index f9de771968..596eb8cf98 100644
--- a/libs/core/tests/unit_tests/language_models/chat_models/test_base.py
+++ b/libs/core/tests/unit_tests/language_models/chat_models/test_base.py
@@ -165,9 +165,9 @@ async def test_stream_error_callback() -> None:
cb_async = FakeAsyncCallbackHandler()
llm_astream = llm.astream("Dummy message", config={"callbacks": [cb_async]})
for _ in range(i):
- await llm_astream.__anext__()
+ await anext(llm_astream)
with pytest.raises(FakeListChatModelError):
- await llm_astream.__anext__()
+ await anext(llm_astream)
eval_response(cb_async, i)
cb_sync = FakeCallbackHandler()
diff --git a/libs/core/tests/unit_tests/messages/block_translators/test_openai.py b/libs/core/tests/unit_tests/messages/block_translators/test_openai.py
index 7d575b5794..b39b768993 100644
--- a/libs/core/tests/unit_tests/messages/block_translators/test_openai.py
+++ b/libs/core/tests/unit_tests/messages/block_translators/test_openai.py
@@ -385,8 +385,9 @@ def test_compat_responses_v03() -> None:
]
assert message_v03.content_blocks == expected_content
- # Test chunks
- ## Tool calls
+ # --- Test chunks --- #
+
+ # Tool calls
chunk_1 = AIMessageChunk(
content=[],
additional_kwargs={"__openai_function_call_ids__": {"call_abc": "fc_abc"}},
@@ -443,7 +444,7 @@ def test_compat_responses_v03() -> None:
]
assert chunk.content_blocks == expected_content
- ## Reasoning
+ # Reasoning
chunk_1 = AIMessageChunk(
content=[],
additional_kwargs={
@@ -477,7 +478,7 @@ def test_compat_responses_v03() -> None:
def test_convert_to_openai_data_block() -> None:
# Chat completions
- ## Image / url
+ # Image / url
block = {
"type": "image",
"url": "https://example.com/test.png",
@@ -489,7 +490,7 @@ def test_convert_to_openai_data_block() -> None:
result = convert_to_openai_data_block(block)
assert result == expected
- ## Image / base64
+ # Image / base64
block = {
"type": "image",
"base64": "<base64 string>",
@@ -502,7 +503,7 @@ def test_convert_to_openai_data_block() -> None:
result = convert_to_openai_data_block(block)
assert result == expected
- ## File / url
+ # File / url
block = {
"type": "file",
"url": "https://example.com/test.pdf",
@@ -510,7 +511,7 @@ def test_convert_to_openai_data_block() -> None:
with pytest.raises(ValueError, match="does not support"):
result = convert_to_openai_data_block(block)
- ## File / base64
+ # File / base64
block = {
"type": "file",
"base64": "<base64 string>",
@@ -527,7 +528,7 @@ def test_convert_to_openai_data_block() -> None:
result = convert_to_openai_data_block(block)
assert result == expected
- ## File / file ID
+ # File / file ID
block = {
"type": "file",
"file_id": "file-abc123",
@@ -536,7 +537,7 @@ def test_convert_to_openai_data_block() -> None:
result = convert_to_openai_data_block(block)
assert result == expected
- ## Audio / base64
+ # Audio / base64
block = {
"type": "audio",
"base64": "<base64 string>",
@@ -550,7 +551,7 @@ def test_convert_to_openai_data_block() -> None:
assert result == expected
# Responses
- ## Image / url
+ # Image / url
block = {
"type": "image",
"url": "https://example.com/test.png",
@@ -559,7 +560,7 @@ def test_convert_to_openai_data_block() -> None:
result = convert_to_openai_data_block(block, api="responses")
assert result == expected
- ## Image / base64
+ # Image / base64
block = {
"type": "image",
"base64": "<base64 string>",
@@ -572,14 +573,14 @@ def test_convert_to_openai_data_block() -> None:
result = convert_to_openai_data_block(block, api="responses")
assert result == expected
- ## File / url
+ # File / url
block = {
"type": "file",
"url": "https://example.com/test.pdf",
}
expected = {"type": "input_file", "file_url": "https://example.com/test.pdf"}
- ## File / base64
+ # File / base64
block = {
"type": "file",
"base64": "<base64 string>",
@@ -594,7 +595,7 @@ def test_convert_to_openai_data_block() -> None:
result = convert_to_openai_data_block(block, api="responses")
assert result == expected
- ## File / file ID
+ # File / file ID
block = {
"type": "file",
"file_id": "file-abc123",
diff --git a/libs/core/tests/unit_tests/output_parsers/test_pydantic_parser.py b/libs/core/tests/unit_tests/output_parsers/test_pydantic_parser.py
index 2df7de3575..9f49c1748f 100644
--- a/libs/core/tests/unit_tests/output_parsers/test_pydantic_parser.py
+++ b/libs/core/tests/unit_tests/output_parsers/test_pydantic_parser.py
@@ -23,7 +23,10 @@ class ForecastV2(pydantic.BaseModel):
forecast: str
-if sys.version_info < (3, 14):
+if sys.version_info >= (3, 14):
+ _FORECAST_MODELS_TYPES = type[ForecastV2]
+ _FORECAST_MODELS = [ForecastV2]
+else:
class ForecastV1(V1BaseModel):
temperature: int
@@ -32,9 +35,6 @@ if sys.version_info < (3, 14):
_FORECAST_MODELS_TYPES = type[ForecastV2] | type[ForecastV1]
_FORECAST_MODELS = [ForecastV2, ForecastV1]
-else:
- _FORECAST_MODELS_TYPES = type[ForecastV2]
- _FORECAST_MODELS = [ForecastV2]
@pytest.mark.parametrize("pydantic_object", _FORECAST_MODELS)
diff --git a/libs/core/tests/unit_tests/runnables/test_runnable.py b/libs/core/tests/unit_tests/runnables/test_runnable.py
index 4e82358d9b..0d8f586386 100644
--- a/libs/core/tests/unit_tests/runnables/test_runnable.py
+++ b/libs/core/tests/unit_tests/runnables/test_runnable.py
@@ -4,7 +4,13 @@ import sys
import time
import uuid
import warnings
-from collections.abc import AsyncIterator, Awaitable, Callable, Iterator, Sequence
+from collections.abc import (
+ AsyncIterator,
+ Awaitable,
+ Callable,
+ Iterator,
+ Sequence,
+)
from functools import partial
from operator import itemgetter
from typing import Any, cast
diff --git a/libs/core/tests/unit_tests/runnables/test_runnable_events_v1.py b/libs/core/tests/unit_tests/runnables/test_runnable_events_v1.py
index 0b30aa58be..2023c82630 100644
--- a/libs/core/tests/unit_tests/runnables/test_runnable_events_v1.py
+++ b/libs/core/tests/unit_tests/runnables/test_runnable_events_v1.py
@@ -1542,7 +1542,7 @@ async def test_chain_ordering() -> None:
try:
for _ in range(10):
- next_chunk = await iterable.__anext__()
+ next_chunk = await anext(iterable)
events.append(next_chunk)
except Exception:
pass
@@ -1659,7 +1659,7 @@ async def test_event_stream_with_retry() -> None:
try:
for _ in range(10):
- next_chunk = await iterable.__anext__()
+ next_chunk = await anext(iterable)
events.append(next_chunk)
except Exception:
pass
diff --git a/libs/core/tests/unit_tests/runnables/test_runnable_events_v2.py b/libs/core/tests/unit_tests/runnables/test_runnable_events_v2.py
index 42e95d6b16..f36648d0c0 100644
--- a/libs/core/tests/unit_tests/runnables/test_runnable_events_v2.py
+++ b/libs/core/tests/unit_tests/runnables/test_runnable_events_v2.py
@@ -1504,7 +1504,7 @@ async def test_chain_ordering() -> None:
try:
for _ in range(10):
- next_chunk = await iterable.__anext__()
+ next_chunk = await anext(iterable)
events.append(next_chunk)
except Exception:
pass
@@ -1621,7 +1621,7 @@ async def test_event_stream_with_retry() -> None:
try:
for _ in range(10):
- next_chunk = await iterable.__anext__()
+ next_chunk = await anext(iterable)
events.append(next_chunk)
except Exception:
pass
diff --git a/libs/core/tests/unit_tests/test_messages.py b/libs/core/tests/unit_tests/test_messages.py
index ff8183e527..92b00c8403 100644
--- a/libs/core/tests/unit_tests/test_messages.py
+++ b/libs/core/tests/unit_tests/test_messages.py
@@ -1105,20 +1105,32 @@ def test_is_data_content_block() -> None:
# Image blocks
assert is_data_content_block({"type": "image", "url": "https://..."})
assert is_data_content_block(
- {"type": "image", "base64": "<base64 data>", "mime_type": "image/jpeg"}
+ {
+ "type": "image",
+ "base64": "<base64 data>",
+ "mime_type": "image/jpeg",
+ }
)
# Video blocks
assert is_data_content_block({"type": "video", "url": "https://video.mp4"})
assert is_data_content_block(
- {"type": "video", "base64": "<base64 video>", "mime_type": "video/mp4"}
+ {
+ "type": "video",
+ "base64": "<base64 video>",
+ "mime_type": "video/mp4",
+ }
)
assert is_data_content_block({"type": "video", "file_id": "vid_123"})
# Audio blocks
assert is_data_content_block({"type": "audio", "url": "https://audio.mp3"})
assert is_data_content_block(
- {"type": "audio", "base64": "<base64 audio>", "mime_type": "audio/mp3"}
+ {
+ "type": "audio",
+ "base64": "<base64 audio>",
+ "mime_type": "audio/mp3",
+ }
)
assert is_data_content_block({"type": "audio", "file_id": "aud_123"})
@@ -1130,7 +1142,11 @@ def test_is_data_content_block() -> None:
# File blocks
assert is_data_content_block({"type": "file", "url": "https://file.pdf"})
assert is_data_content_block(
- {"type": "file", "base64": "<base64 file>", "mime_type": "application/pdf"}
+ {
+ "type": "file",
+ "base64": "<base64 file>",
+ "mime_type": "application/pdf",
+ }
)
assert is_data_content_block({"type": "file", "file_id": "file_123"})
diff --git a/libs/core/tests/unit_tests/tracers/test_langchain.py b/libs/core/tests/unit_tests/tracers/test_langchain.py
index 011b801b8a..5cb29d82ea 100644
--- a/libs/core/tests/unit_tests/tracers/test_langchain.py
+++ b/libs/core/tests/unit_tests/tracers/test_langchain.py
@@ -1,6 +1,5 @@
import threading
import time
-import unittest
import unittest.mock
import uuid
from typing import Any
diff --git a/libs/core/tests/unit_tests/vectorstores/test_in_memory.py b/libs/core/tests/unit_tests/vectorstores/test_in_memory.py
index af80c9742f..f758223388 100644
--- a/libs/core/tests/unit_tests/vectorstores/test_in_memory.py
+++ b/libs/core/tests/unit_tests/vectorstores/test_in_memory.py
@@ -138,7 +138,7 @@ async def test_inmemory_filter_by_document_id() -> None:
# Test async version
output = await store.asimilarity_search(
- "document", filter=lambda doc: doc.id in ["doc_1", "doc_3"]
+ "document", filter=lambda doc: doc.id in {"doc_1", "doc_3"}
)
assert len(output) == 2
ids = {doc.id for doc in output}