Skip to content

Commit c55af44

Browse files
author
Erick Friis
authored
anthropic: pydantic mypy plugin (#29144)
1 parent cdf3a17 commit c55af44

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

libs/partners/anthropic/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ license = "MIT"
1313

1414
[tool.mypy]
1515
disallow_untyped_defs = "True"
16+
plugins = ['pydantic.mypy']
1617

1718
[tool.poetry.urls]
1819
"Source Code" = "https://github.com/langchain-ai/langchain/tree/master/libs/partners/anthropic"

libs/partners/anthropic/tests/integration_tests/test_chat_models.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ async def test_abatch_tags() -> None:
153153

154154

155155
async def test_async_tool_use() -> None:
156-
llm = ChatAnthropic( # type: ignore[call-arg]
156+
llm = ChatAnthropic(
157157
model=MODEL_NAME,
158158
)
159159

@@ -249,7 +249,7 @@ def test_system_invoke() -> None:
249249

250250
def test_anthropic_call() -> None:
251251
"""Test valid call to anthropic."""
252-
chat = ChatAnthropic(model=MODEL_NAME) # type: ignore[call-arg]
252+
chat = ChatAnthropic(model=MODEL_NAME)
253253
message = HumanMessage(content="Hello")
254254
response = chat.invoke([message])
255255
assert isinstance(response, AIMessage)
@@ -258,7 +258,7 @@ def test_anthropic_call() -> None:
258258

259259
def test_anthropic_generate() -> None:
260260
"""Test generate method of anthropic."""
261-
chat = ChatAnthropic(model=MODEL_NAME) # type: ignore[call-arg]
261+
chat = ChatAnthropic(model=MODEL_NAME)
262262
chat_messages: List[List[BaseMessage]] = [
263263
[HumanMessage(content="How many toes do dogs have?")]
264264
]
@@ -274,7 +274,7 @@ def test_anthropic_generate() -> None:
274274

275275
def test_anthropic_streaming() -> None:
276276
"""Test streaming tokens from anthropic."""
277-
chat = ChatAnthropic(model=MODEL_NAME) # type: ignore[call-arg]
277+
chat = ChatAnthropic(model=MODEL_NAME)
278278
message = HumanMessage(content="Hello")
279279
response = chat.stream([message])
280280
for token in response:
@@ -286,7 +286,7 @@ def test_anthropic_streaming_callback() -> None:
286286
"""Test that streaming correctly invokes on_llm_new_token callback."""
287287
callback_handler = FakeCallbackHandler()
288288
callback_manager = CallbackManager([callback_handler])
289-
chat = ChatAnthropic( # type: ignore[call-arg]
289+
chat = ChatAnthropic(
290290
model=MODEL_NAME,
291291
callback_manager=callback_manager,
292292
verbose=True,
@@ -302,7 +302,7 @@ async def test_anthropic_async_streaming_callback() -> None:
302302
"""Test that streaming correctly invokes on_llm_new_token callback."""
303303
callback_handler = FakeCallbackHandler()
304304
callback_manager = CallbackManager([callback_handler])
305-
chat = ChatAnthropic( # type: ignore[call-arg]
305+
chat = ChatAnthropic(
306306
model=MODEL_NAME,
307307
callback_manager=callback_manager,
308308
verbose=True,
@@ -318,7 +318,7 @@ async def test_anthropic_async_streaming_callback() -> None:
318318

319319
def test_anthropic_multimodal() -> None:
320320
"""Test that multimodal inputs are handled correctly."""
321-
chat = ChatAnthropic(model=MODEL_NAME) # type: ignore[call-arg]
321+
chat = ChatAnthropic(model=MODEL_NAME)
322322
messages: list[BaseMessage] = [
323323
HumanMessage(
324324
content=[
@@ -369,7 +369,7 @@ async def test_astreaming() -> None:
369369

370370

371371
def test_tool_use() -> None:
372-
llm = ChatAnthropic(model=MODEL_NAME) # type: ignore[call-arg]
372+
llm = ChatAnthropic(model=MODEL_NAME)
373373
llm_with_tools = llm.bind_tools(
374374
[
375375
{
@@ -452,7 +452,7 @@ def type_letter(letter: str) -> str:
452452
"""Type the given letter."""
453453
return "OK"
454454

455-
model = ChatAnthropic(model="claude-3-opus-20240229", temperature=0).bind_tools( # type: ignore[call-arg]
455+
model = ChatAnthropic(model="claude-3-opus-20240229", temperature=0).bind_tools(
456456
[type_letter]
457457
)
458458

@@ -490,7 +490,7 @@ def type_letter(letter: str) -> str:
490490

491491

492492
def test_with_structured_output() -> None:
493-
llm = ChatAnthropic( # type: ignore[call-arg]
493+
llm = ChatAnthropic(
494494
model="claude-3-opus-20240229",
495495
)
496496

@@ -510,7 +510,7 @@ def test_with_structured_output() -> None:
510510

511511

512512
def test_get_num_tokens_from_messages() -> None:
513-
llm = ChatAnthropic(model="claude-3-5-sonnet-20241022") # type: ignore[call-arg]
513+
llm = ChatAnthropic(model="claude-3-5-sonnet-20241022")
514514

515515
# Test simple case
516516
messages = [
@@ -571,7 +571,7 @@ class GetWeather(BaseModel):
571571

572572
@pytest.mark.parametrize("tool_choice", ["GetWeather", "auto", "any"])
573573
def test_anthropic_bind_tools_tool_choice(tool_choice: str) -> None:
574-
chat_model = ChatAnthropic( # type: ignore[call-arg]
574+
chat_model = ChatAnthropic(
575575
model=MODEL_NAME,
576576
)
577577
chat_model_with_tools = chat_model.bind_tools([GetWeather], tool_choice=tool_choice)
@@ -583,7 +583,7 @@ def test_pdf_document_input() -> None:
583583
url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
584584
data = b64encode(requests.get(url).content).decode()
585585

586-
result = ChatAnthropic(model_name=MODEL_NAME).invoke( # type: ignore[call-arg]
586+
result = ChatAnthropic(model=MODEL_NAME).invoke(
587587
[
588588
HumanMessage(
589589
[

0 commit comments

Comments
 (0)