Skip to content

Commit

Permalink
upgrade mypy and add type ignores
Browse files Browse the repository at this point in the history
  • Loading branch information
ccurme committed Sep 4, 2024
1 parent 0ce81d9 commit 52c5514
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 61 deletions.
80 changes: 33 additions & 47 deletions libs/partners/voyageai/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libs/partners/voyageai/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ optional = true
ruff = "^0.1.5"

[tool.poetry.group.typing.dependencies]
mypy = "^0.991"
mypy = "^1.10"
langchain-core = { path = "../../core", develop = true }

[tool.poetry.group.dev]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def test_langchain_voyageai_embedding_documents() -> None:
"""Test voyage embeddings."""
documents = ["foo bar"]
embedding = VoyageAIEmbeddings(model=MODEL)
embedding = VoyageAIEmbeddings(model=MODEL) # type: ignore[call-arg]
output = embedding.embed_documents(documents)
assert len(output) == 1
assert len(output[0]) == 1024
Expand All @@ -29,7 +29,7 @@ def test_langchain_voyageai_embedding_documents_multiple() -> None:
def test_langchain_voyageai_embedding_query() -> None:
"""Test voyage embeddings."""
document = "foo bar"
embedding = VoyageAIEmbeddings(model=MODEL)
embedding = VoyageAIEmbeddings(model=MODEL) # type: ignore[call-arg]
output = embedding.embed_query(document)
assert len(output) == 1024

Expand All @@ -48,6 +48,6 @@ async def test_langchain_voyageai_async_embedding_documents_multiple() -> None:
async def test_langchain_voyageai_async_embedding_query() -> None:
"""Test voyage embeddings."""
document = "foo bar"
embedding = VoyageAIEmbeddings(model=MODEL)
embedding = VoyageAIEmbeddings(model=MODEL) # type: ignore[call-arg]
output = await embedding.aembed_query(document)
assert len(output) == 1024
6 changes: 3 additions & 3 deletions libs/partners/voyageai/tests/integration_tests/test_rerank.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

def test_voyageai_reranker_init() -> None:
"""Test the voyageai reranker initializes correctly."""
VoyageAIRerank(voyage_api_key="foo", model="foo")
VoyageAIRerank(voyage_api_key="foo", model="foo") # type: ignore[arg-type]


def test_sync() -> None:
rerank = VoyageAIRerank(
voyage_api_key=os.environ["VOYAGE_API_KEY"],
voyage_api_key=os.environ["VOYAGE_API_KEY"], # type: ignore[arg-type]
model="rerank-lite-1",
)
doc_list = [
Expand Down Expand Up @@ -42,7 +42,7 @@ def test_sync() -> None:

async def test_async() -> None:
rerank = VoyageAIRerank(
voyage_api_key=os.environ["VOYAGE_API_KEY"],
voyage_api_key=os.environ["VOYAGE_API_KEY"], # type: ignore[arg-type]
model="rerank-lite-1",
)
doc_list = [
Expand Down
10 changes: 6 additions & 4 deletions libs/partners/voyageai/tests/unit_tests/test_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

def test_initialization_voyage_2() -> None:
"""Test embedding model initialization."""
emb = VoyageAIEmbeddings(api_key="NOT_A_VALID_KEY", model=MODEL)
emb = VoyageAIEmbeddings(api_key="NOT_A_VALID_KEY", model=MODEL) # type: ignore
assert isinstance(emb, Embeddings)
assert emb.batch_size == 72
assert emb.model == MODEL
Expand All @@ -20,7 +20,7 @@ def test_initialization_voyage_2_with_full_api_key_name() -> None:
"""Test embedding model initialization."""
# Testing that we can initialize the model using `voyage_api_key`
# instead of `api_key`
emb = VoyageAIEmbeddings(voyage_api_key="NOT_A_VALID_KEY", model=MODEL)
emb = VoyageAIEmbeddings(voyage_api_key="NOT_A_VALID_KEY", model=MODEL) # type: ignore
assert isinstance(emb, Embeddings)
assert emb.batch_size == 72
assert emb.model == MODEL
Expand All @@ -29,7 +29,7 @@ def test_initialization_voyage_2_with_full_api_key_name() -> None:

def test_initialization_voyage_1() -> None:
"""Test embedding model initialization."""
emb = VoyageAIEmbeddings(api_key="NOT_A_VALID_KEY", model="voyage-01")
emb = VoyageAIEmbeddings(api_key="NOT_A_VALID_KEY", model="voyage-01") # type: ignore
assert isinstance(emb, Embeddings)
assert emb.batch_size == 7
assert emb.model == "voyage-01"
Expand All @@ -39,7 +39,9 @@ def test_initialization_voyage_1() -> None:
def test_initialization_voyage_1_batch_size() -> None:
"""Test embedding model initialization."""
emb = VoyageAIEmbeddings(
api_key="NOT_A_VALID_KEY", model="voyage-01", batch_size=15
api_key="NOT_A_VALID_KEY", # type: ignore
model="voyage-01",
batch_size=15,
)
assert isinstance(emb, Embeddings)
assert emb.batch_size == 15
Expand Down
6 changes: 3 additions & 3 deletions libs/partners/voyageai/tests/unit_tests/test_rerank.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@pytest.mark.requires("voyageai")
def test_init() -> None:
VoyageAIRerank(
voyage_api_key="foo",
voyage_api_key="foo", # type: ignore[arg-type]
model="rerank-lite-1",
)

Expand Down Expand Up @@ -63,7 +63,7 @@ def test_rerank_unit_test(mocker: Any) -> None:
]

rerank = VoyageAIRerank(
voyage_api_key="foo",
voyage_api_key="foo", # type: ignore[arg-type]
model="rerank-lite-1",
)
result = rerank.compress_documents(
Expand All @@ -74,7 +74,7 @@ def test_rerank_unit_test(mocker: Any) -> None:

def test_rerank_empty_input() -> None:
rerank = VoyageAIRerank(
voyage_api_key="foo",
voyage_api_key="foo", # type: ignore[arg-type]
model="rerank-lite-1",
)
result = rerank.compress_documents(
Expand Down

0 comments on commit 52c5514

Please sign in to comment.