Skip to content

fix(api): restore BM25Scorer + dedupe Fts5BM25Index after botched merge — main is currently a SyntaxError#341

Merged
ASuresh0524 merged 1 commit into
StarTrail-org:mainfrom
raoabinav:fix/api-bm25scorer-half-deleted-syntax-error
May 27, 2026
Merged

fix(api): restore BM25Scorer + dedupe Fts5BM25Index after botched merge — main is currently a SyntaxError#341
ASuresh0524 merged 1 commit into
StarTrail-org:mainfrom
raoabinav:fix/api-bm25scorer-half-deleted-syntax-error

Conversation

@raoabinav
Copy link
Copy Markdown
Contributor

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:

  1. `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.

  2. `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:

  • `ast.parse` succeeds.
  • `ruff format && ruff check && ty check ...` all clean on api.py.
  • No behavior change beyond "main can be imported again".

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.

`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>
@ASuresh0524 ASuresh0524 merged commit a996b35 into StarTrail-org:main May 27, 2026
31 checks passed
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.

2 participants