Skip to content

build(mypy): ignore missing stubs for sentence_transformers#95

Open
RobertSigmundsson wants to merge 1 commit into
acidkill:mainfrom
RobertSigmundsson:upstream-pr/mypy-sentence-transformers
Open

build(mypy): ignore missing stubs for sentence_transformers#95
RobertSigmundsson wants to merge 1 commit into
acidkill:mainfrom
RobertSigmundsson:upstream-pr/mypy-sentence-transformers

Conversation

@RobertSigmundsson

Copy link
Copy Markdown
Contributor

Problem

sentence_transformers ships no type stubs. It is absent from the existing
[[tool.mypy.overrides]] block that already lists networkx.*, chromadb.*, openpyxl.*,
google.genai.* and watchdog.* — so in any environment where the package is installed, mypy
reports import errors for it while every comparable dependency is exempt.

Change

One line in pyproject.toml:

[[tool.mypy.overrides]]
module = [
    ...
    "watchdog.*",
+   "sentence_transformers.*",
]
ignore_missing_imports = true

Why upstream benefits

Consistency with every other stub-less optional dependency already handled the same way, and a clean
mypy run for contributors who have the package installed.

Evidence

Check Result
cherry-pick onto origin/main clean
import surreal_memory OK
ruff check All checks passed!
ruff format --check 701 files already formatted
mypy src/ --ignore-missing-imports Success: no issues found in 369 source files
pytest -m "not stress" -n auto 6535 passed, 84 skipped, 1 xfailed — identical to baseline

Risks / notes for the reviewer

  • Effectively none. The gate passes with and without it in an environment where the package is not
    installed; the change only matters where it is.
  • Worth merging first — it is a one-liner and it is a prerequisite for a clean mypy on any branch that
    imports sentence_transformers.

sentence_transformers is an optional runtime dep (guarded by try/except
ImportError in reranker.py and semantic_discovery.py) not installed in the
test venv, so mypy reported import-not-found. Add it to the existing
ignore_missing_imports override list (CS-1) so the fork's mypy gate is fully
green without touching the optional-import guards.

(cherry picked from commit 36a7e47)
(cherry picked from commit 92b6577)
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.

1 participant