fix(api): restore BM25Scorer + dedupe Fts5BM25Index after botched merge — main is currently a SyntaxError#341
Merged
ASuresh0524 merged 1 commit intoMay 27, 2026
Conversation
`packages/leann-core/src/leann/api.py` on `main` is currently a Python
SyntaxError. Repro: `python3 -c "import ast; ast.parse(open('packages/leann-core/src/leann/api.py').read())"`
fails at line 318 with `unterminated string literal`.
Two problems left over from a recent merge:
- `BM25Scorer` has its class header + `__init__` but the methods (`_tokenize`,
`fit`, `score`, `search`) were removed. The space between `__init__` and the
next sibling now holds an orphan docstring fragment ("Today's only
implementation is `Fts5BM25Index`...") with no opening `"""`, plus a stray
`@abstractmethod fit/search` block that belongs to the `BM25Index` ABC. That
unmatched `"""` is the actual SyntaxError.
- `class Fts5BM25Index(BM25Index):` appears twice in the file (formerly lines
341 and 409). Python silently kept the second; the first was dead code.
Effect on CI: every open PR fails because GitHub Actions checks out the merge
preview (branch + main), which inherits main's broken file.
This patch restores `BM25Scorer`'s methods (taken from the pre-StarTrail-org#335 history,
matching what `BM25Index` declares the contract to be), drops the orphan
abstractmethod block, and removes the duplicate `Fts5BM25Index` class. After
the patch, `ast.parse` succeeds and ty reports no api.py diagnostics. No
behavior change beyond "main can be imported again".
If the intent was actually to complete the `StarTrail-org#335 drop BM25Scorer` removal,
this PR is the wrong direction — closing it and following up with a real
deletion is fine. But until either path lands, every other PR is stuck.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Main is currently a Python SyntaxError. Quick repro from a fresh clone:
```
python3 -c "import ast; ast.parse(open('packages/leann-core/src/leann/api.py').read())"
SyntaxError: unterminated string literal at line 318
```
Two leftovers from a recent merge in api.py:
`BM25Scorer` is half-deleted. The class header + `init` survived; the methods (`_tokenize`, `fit`, `score`, `search`) are gone. Between `init` and the next class sits an orphan docstring fragment ("Today's only implementation is `Fts5BM25Index`...") with no opening `"""`, plus an `@abstractmethod fit/search` block that belongs to the `BM25Index` ABC. The unmatched `"""` is the actual SyntaxError.
`class Fts5BM25Index(BM25Index):` appears twice (was at lines 341 and 409). Python keeps the second, so the first was dead code.
Effect on CI
Every open PR fails right now, because GitHub Actions on `pull_request` events checks out the merge preview (branch + main) by default — which inherits main's broken file. That's why several PRs that were green a few days ago suddenly went red without their own code changing.
What this PR does
After the patch:
If the intent was different
If the merge was supposed to complete #335's `drop BM25Scorer` removal (the train's final sub-PR), this PR is the wrong direction — close it and follow up with a clean deletion PR instead. Either path unblocks the rest of the open PRs; this is just the smaller diff.
lmk if you'd prefer the deletion route and I'll redo.