partners[lint]: run pyupgrade to get code in line with 3.9 standards (#30781)

Using `pyupgrade` to get all `partners` code up to 3.9 standards
(mostly, fixing old `typing` imports).
This commit is contained in:
Sydney Runkle
2025-04-11 07:18:44 -04:00
committed by GitHub
parent e72f3c26a0
commit 8c6734325b
123 changed files with 1000 additions and 1109 deletions

View File

@@ -1,5 +1,4 @@
from abc import ABC, abstractmethod
from typing import List
from langchain_core.runnables.config import run_in_executor
from pydantic import BaseModel, Field
@@ -10,8 +9,8 @@ class SparseVector(BaseModel, extra="forbid"):
Sparse vector structure
"""
indices: List[int] = Field(..., description="indices must be unique")
values: List[float] = Field(
indices: list[int] = Field(..., description="indices must be unique")
values: list[float] = Field(
..., description="values and indices must be the same length"
)
@@ -20,14 +19,14 @@ class SparseEmbeddings(ABC):
"""An interface for sparse embedding models to use with Qdrant."""
@abstractmethod
def embed_documents(self, texts: List[str]) -> List[SparseVector]:
def embed_documents(self, texts: list[str]) -> list[SparseVector]:
"""Embed search docs."""
@abstractmethod
def embed_query(self, text: str) -> SparseVector:
"""Embed query text."""
async def aembed_documents(self, texts: List[str]) -> List[SparseVector]:
async def aembed_documents(self, texts: list[str]) -> list[SparseVector]:
"""Asynchronous Embed search docs."""
return await run_in_executor(None, self.embed_documents, texts)