Skip to content

fix(sqlserver): fix ruff formatting and mypy errors in async vector store methods - #793

Merged
Facundo Santiago (santiagxf) merged 8 commits into
mainfrom
copilot/fix-ci-cd-libs-sqlserver-make-lint
Jun 30, 2026
Merged

fix(sqlserver): fix ruff formatting and mypy errors in async vector store methods#793
Facundo Santiago (santiagxf) merged 8 commits into
mainfrom
copilot/fix-ci-cd-libs-sqlserver-make-lint

Conversation

Copilot AI commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

CI (make lint) was failing on PR #633's async additions to SQLServer_VectorStore due to two issues in langchain_sqlserver/vectorstores.py.

Changes

  • Ruff formatting: collapsed three overly-split expressions to single lines (within ruff's line-length budget):

    • connection_string.replace("mssql+pyodbc", "mssql+aioodbc", 1)
    • return await self.aadd_texts(texts, metadatas=metadatas, ids=ids, **kwargs)
    • await session.execute(insert(self._embedding_store).values(documents))
  • Mypy attr-defined errors in adelete: SQLAlchemy's type stubs declare AsyncSession.execute() as returning Result[Any], which lacks rowcount. The DML result variable is annotated as Any to allow .rowcount access without fighting the stubs.

DevNinja (0xDevNinja) and others added 6 commits May 28, 2026 19:59
Adds an async surface to `SQLServer_VectorStore` so callers running
inside an asyncio event loop don't block it on synchronous ODBC I/O.

New methods mirror the sync API one-for-one:

- `aadd_texts`, `aadd_documents`
- `afrom_texts`, `afrom_documents` (classmethods)
- `asimilarity_search`, `asimilarity_search_by_vector`,
  `asimilarity_search_with_score`, `asimilarity_search_by_vector_with_score`
- `aget_by_ids`, `adelete`

The async path uses SQLAlchemy's `create_async_engine` with the
`mssql+aioodbc` driver. The async engine is built lazily on first use
(and cached) so synchronous-only callers do not pay any aioodbc cost.
Entra ID authentication uses the same connection-event token provider
as the sync engine, so connection-string conventions stay identical.

If the embedding function exposes `aembed_documents` / `aembed_query`,
the async path uses those; otherwise it falls back to the sync
embedding API so existing `Embeddings` implementations keep working.

Adds `aioodbc~=0.5` as a project dependency.

Closes #16
Copilot AI changed the title [WIP] Fix failing GitHub Actions job for SQL Server linting fix(sqlserver): fix ruff formatting and mypy errors in async vector store methods Jun 30, 2026
@santiagxf
Facundo Santiago (santiagxf) marked this pull request as ready for review June 30, 2026 19:19
@santiagxf
Facundo Santiago (santiagxf) merged commit 1361733 into main Jun 30, 2026
11 checks passed
@santiagxf
Facundo Santiago (santiagxf) deleted the copilot/fix-ci-cd-libs-sqlserver-make-lint branch June 30, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants