Skip to content

Commit 8e7cd85

Browse files
authored
style: drop target-version = "py39" for OpenAI, Anthropic, HuggingFace (#33287)
1 parent 66889e2 commit 8e7cd85

File tree

12 files changed

+22
-28
lines changed

12 files changed

+22
-28
lines changed

libs/partners/anthropic/langchain_anthropic/chat_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import json
77
import re
88
import warnings
9-
from collections.abc import AsyncIterator, Iterator, Mapping, Sequence
9+
from collections.abc import AsyncIterator, Callable, Iterator, Mapping, Sequence
1010
from functools import cached_property
1111
from operator import itemgetter
12-
from typing import Any, Callable, Final, Literal, Optional, Union, cast
12+
from typing import Any, Final, Literal, Optional, Union, cast
1313

1414
import anthropic
1515
from langchain_core.callbacks import (

libs/partners/anthropic/langchain_anthropic/llms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import re
66
import warnings
7-
from collections.abc import AsyncIterator, Iterator, Mapping
8-
from typing import Any, Callable, Optional
7+
from collections.abc import AsyncIterator, Callable, Iterator, Mapping
8+
from typing import Any, Optional
99

1010
import anthropic
1111
from langchain_core.callbacks import (

libs/partners/anthropic/pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ langchain-tests = { path = "../../standard-tests", editable = true }
5555
disallow_untyped_defs = "True"
5656
plugins = ['pydantic.mypy']
5757

58-
[tool.ruff]
59-
target-version = "py39"
60-
6158
[tool.ruff.format]
6259
docstring-code-format = true
6360
docstring-code-line-length = 100

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from __future__ import annotations
44

55
import os
6-
from typing import Any, Callable, Literal, Optional, cast
6+
from collections.abc import Callable
7+
from typing import Any, Literal, Optional, cast
78
from unittest.mock import MagicMock, patch
89

910
import anthropic

libs/partners/huggingface/pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ langchain-tests = { path = "../../standard-tests", editable = true }
5454
[tool.mypy]
5555
disallow_untyped_defs = "True"
5656

57-
[tool.ruff]
58-
target-version = "py39"
59-
6057
[tool.ruff.format]
6158
docstring-code-format = true
6259
docstring-code-line-length = 100

libs/partners/openai/langchain_openai/chat_models/azure.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import logging
66
import os
7-
from collections.abc import AsyncIterator, Awaitable, Iterator
8-
from typing import Any, Callable, Optional, TypeVar, Union
7+
from collections.abc import AsyncIterator, Awaitable, Callable, Iterator
8+
from typing import Any, Literal, Optional, TypeVar, Union
99

1010
import openai
1111
from langchain_core.language_models import LanguageModelInput
@@ -15,7 +15,7 @@
1515
from langchain_core.utils import from_env, secret_from_env
1616
from langchain_core.utils.pydantic import is_basemodel_subclass
1717
from pydantic import BaseModel, Field, SecretStr, model_validator
18-
from typing_extensions import Literal, Self
18+
from typing_extensions import Self
1919

2020
from langchain_openai.chat_models.base import BaseChatOpenAI
2121

@@ -758,7 +758,7 @@ def _create_chat_result(
758758
"prompt_filter_results"
759759
]
760760
for chat_gen, response_choice in zip(
761-
chat_result.generations, response["choices"]
761+
chat_result.generations, response["choices"], strict=False
762762
):
763763
chat_gen.generation_info = chat_gen.generation_info or {}
764764
chat_gen.generation_info["content_filter_results"] = response_choice.get(

libs/partners/openai/langchain_openai/chat_models/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import ssl
1111
import sys
1212
import warnings
13-
from collections.abc import AsyncIterator, Iterator, Mapping, Sequence
13+
from collections.abc import AsyncIterator, Callable, Iterator, Mapping, Sequence
1414
from functools import partial
1515
from io import BytesIO
1616
from json import JSONDecodeError
@@ -19,7 +19,6 @@
1919
from typing import (
2020
TYPE_CHECKING,
2121
Any,
22-
Callable,
2322
Literal,
2423
Optional,
2524
TypeVar,

libs/partners/openai/langchain_openai/embeddings/azure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
from __future__ import annotations
44

5-
from collections.abc import Awaitable
6-
from typing import Callable, Optional, Union, cast
5+
from collections.abc import Awaitable, Callable
6+
from typing import Optional, Union, cast
77

88
import openai
99
from langchain_core.utils import from_env, secret_from_env

libs/partners/openai/langchain_openai/embeddings/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@ def _process_batched_chunked_embeddings(
6262
# average = np.average(_result, axis=0, weights=num_tokens_in_batch[i])
6363
total_weight = sum(num_tokens_in_batch[i])
6464
average = [
65-
sum(val * weight for val, weight in zip(embedding, num_tokens_in_batch[i]))
65+
sum(
66+
val * weight
67+
for val, weight in zip(embedding, num_tokens_in_batch[i], strict=False)
68+
)
6669
/ total_weight
67-
for embedding in zip(*_result)
70+
for embedding in zip(*_result, strict=False)
6871
]
6972

7073
# should be same as

libs/partners/openai/langchain_openai/llms/azure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from __future__ import annotations
44

55
import logging
6-
from collections.abc import Awaitable, Mapping
7-
from typing import Any, Callable, Optional, Union, cast
6+
from collections.abc import Awaitable, Callable, Mapping
7+
from typing import Any, Optional, Union, cast
88

99
import openai
1010
from langchain_core.language_models import LangSmithParams

0 commit comments

Comments
 (0)