Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
# Starting new jobs is also relatively slow,
# so linting on fewer versions makes CI faster.
python-version:
- "3.9"
- "3.10"
- "3.13"
steps:
- uses: actions/checkout@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
python-version:
- "3.9"
- "3.10"
- "3.13"
name: "run test #${{ matrix.python-version }}"
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
uses: astral-sh/setup-uv@2ddd2b9cb38ad8efd50337e8ab201519a34c9f24 # v7
with:
enable-cache: true
python-version: 3.9
python-version: "3.10"
- run: just docs

ci_success:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.8.5
rev: v0.14.2
hooks:
# Run the linter.
- id: ruff
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,8 @@ just codespell
```

If codespell is incorrectly flagging a word, you can skip spellcheck for that word by adding it to the codespell config in the `.pre-commit-config.yaml` file.

### CI Configuration
The CI configuration for this project is located in the `.github/workflows` directory.
The `.github/scripts/check_diff.py` script is run automatically at the start of CI to determine which parts of the codebase have changed and need to be tested. I
f you add new packages or change the directory structure, update this script accordingly.
2 changes: 1 addition & 1 deletion docs/_extensions/gallery_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def run(self) -> List[nodes.Node]:

# Parse the template with Sphinx Design to create an output container
# Prep the options for the template grid
class_ = "gallery-directive" + f' {self.options.get("class-container", "")}'
class_ = "gallery-directive" + f" {self.options.get('class-container', '')}"
options = {"gutter": 2, "class-container": class_}
options_str = "\n".join(f":{k}: {v}" for k, v in options.items())

Expand Down
8 changes: 4 additions & 4 deletions docs/create_api_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def _construct_doc(
.. _{package_namespace}:

======================================
{package_namespace.replace('_', '-').replace('.', '-')}: {package_version}
{package_namespace.replace("_", "-").replace(".", "-")}: {package_version}
======================================

.. automodule:: {package_namespace}
Expand Down Expand Up @@ -327,7 +327,7 @@ def _construct_doc(

index_autosummary += f"""
:ref:`{package_namespace}_{module}`
{'^' * (len(package_namespace) + len(module) + 8)}
{"^" * (len(package_namespace) + len(module) + 8)}
"""

if classes:
Expand Down Expand Up @@ -366,7 +366,7 @@ def _construct_doc(

"""
index_autosummary += f"""
{class_['qualified_name']}
{class_["qualified_name"]}
"""

if functions:
Expand Down Expand Up @@ -429,7 +429,7 @@ def _construct_doc(

"""
index_autosummary += f"""
{class_['qualified_name']}
{class_["qualified_name"]}
"""

if deprecated_functions:
Expand Down
8 changes: 5 additions & 3 deletions libs/langchain-mongodb/langchain_mongodb/docstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ def mset(
batch_size: Number of documents to insert at a time.
Tuning this may help with performance and sidestep MongoDB limits.
"""
keys, docs = zip(*key_value_pairs)
keys, docs = zip(*key_value_pairs, strict=True)
n_docs = len(docs)
start = 0
for end in range(batch_size, n_docs + batch_size, batch_size):
texts, metadatas = zip(
*[(doc.page_content, doc.metadata) for doc in docs[start:end]]
*[(doc.page_content, doc.metadata) for doc in docs[start:end]],
strict=True,
)
self.insert_many(texts=texts, metadatas=metadatas, ids=keys[start:end]) # type: ignore
start = end
Expand Down Expand Up @@ -149,6 +150,7 @@ def insert_many(
in the batch that do not have conflicting _ids will still be inserted.
"""
to_insert = [
{"_id": i, self._text_key: t, **m} for i, t, m in zip(ids, texts, metadatas)
{"_id": i, self._text_key: t, **m}
for i, t, m in zip(ids, texts, metadatas, strict=True)
]
self.collection.insert_many(to_insert) # type: ignore
2 changes: 1 addition & 1 deletion libs/langchain-mongodb/langchain_mongodb/indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def update(
if len(keys) != len(group_ids):
raise ValueError("Number of keys does not match number of group_ids")

for key, group_id in zip(keys, group_ids):
for key, group_id in zip(keys, group_ids, strict=True):
self._collection.find_one_and_update(
{"namespace": self.namespace, "key": key},
{"$set": {"group_id": group_id, "updated_at": self.get_time()}},
Expand Down
9 changes: 6 additions & 3 deletions libs/langchain-mongodb/langchain_mongodb/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def add_texts(
metadatas_batch = []
size = 0
i = 0
for j, (text, metadata) in enumerate(zip(texts, _metadatas)):
for j, (text, metadata) in enumerate(zip(texts, _metadatas, strict=True)):
size += len(text) + len(metadata)
texts_batch.append(text)
metadatas_batch.append(metadata)
Expand Down Expand Up @@ -442,7 +442,9 @@ def bulk_embed_and_insert_texts(
self._embedding_key: embedding,
**m,
}
for i, t, m, embedding in zip(ids, texts, metadatas, embeddings)
for i, t, m, embedding in zip(
ids, texts, metadatas, embeddings, strict=True
)
]
operations = [ReplaceOne({"_id": doc["_id"]}, doc, upsert=True) for doc in docs]
# insert the documents in MongoDB Atlas
Expand Down Expand Up @@ -478,7 +480,8 @@ def add_documents(
start = 0
for end in range(batch_size, n_docs + batch_size, batch_size):
texts, metadatas = zip(
*[(doc.page_content, doc.metadata) for doc in documents[start:end]]
*[(doc.page_content, doc.metadata) for doc in documents[start:end]],
strict=True,
)
result_ids.extend(
self.bulk_embed_and_insert_texts(
Expand Down
4 changes: 2 additions & 2 deletions libs/langchain-mongodb/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name = "langchain-mongodb"
version = "0.7.2"
description = "An integration package connecting MongoDB and LangChain"
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.10"
dependencies = [
"langchain-core>=0.3,<1.0",
"langchain>=0.3,<1.0",
Expand Down Expand Up @@ -77,7 +77,7 @@ lint.select = [
"B", # flake8-bugbear
"I", # isort
]
lint.ignore = ["E501", "B008", "UP007", "UP006", "UP035"]
lint.ignore = ["E501", "B008", "UP007", "UP006", "UP035", "UP045"]

[tool.coverage.run]
omit = ["tests/*"]
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def test_mongodb_atlas_cache_matrix(
for prompt_i_generations in generations
]

for prompt_i, llm_generations_i in zip(prompts, llm_generations):
for prompt_i, llm_generations_i in zip(prompts, llm_generations, strict=True):
_execute_test(prompt_i, llm_string, llm_generations_i)
assert llm.generate(prompts) == LLMResult(
generations=llm_generations, llm_output={}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"Demonstrates MongoDBAtlasVectorSearch.as_retriever() invoked in a chain" ""
"Demonstrates MongoDBAtlasVectorSearch.as_retriever() invoked in a chain"

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion libs/langchain-mongodb/tests/unit_tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def test_mongodb_atlas_cache_matrix(
for prompt_i_generations in generations
]

for prompt_i, llm_generations_i in zip(prompts, llm_generations):
for prompt_i, llm_generations_i in zip(prompts, llm_generations, strict=True):
_execute_test(prompt_i, llm_string, llm_generations_i)

get_llm_cache()._collection._simulate_cache_aggregation_query = True # type: ignore
Expand Down
Loading
Loading