Improve missing-attribute suggestions: Jaro-Winkler similarity, gated containment - #147
Merged
jhonabreul merged 4 commits intoAug 12, 2026
Conversation
5 tasks
jhonabreul
marked this pull request as ready for review
August 11, 2026 17:51
Martin-Molinero
approved these changes
Aug 11, 2026
Keeps the Jaro-Winkler scoring from this branch in ClassBase while retaining Util.LevenshteinDistance, which MethodBinder's unexpected-kwarg suggestion (QuantConnect#144) still uses. Also moves the DiagnoseClosestOverloadMismatch block inside the bind-failure try so master compiles again: QuantConnect#144 wrapped the message construction (including the candidates declaration) in try/catch after QuantConnect#145 had added the mismatch diagnosis below it, leaving 'candidates' out of scope at its use site.
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.
What does this implement/fix? Explain your changes.
Improves the quality of the "Did you mean" hints on missing-attribute errors, fixing two defects in how similar member names are selected:
1–2 letter members flooded the hint for long missed names. The substring-containment test admitted any member that appears inside the missed name, and types like
QCAlgorithmexpose many 1–2 letter members (indicator shortcuts, greek letters), every one of which is a substring of a long name:Containment now only counts for fragments of at least 3 characters, and a candidate contained in the missed name must additionally cover at least half of it.
Suffix-extended members were never suggested. The Levenshtein threshold
max(2, len/3)rejected members whose real name extends the guess with a suffix, so the member the user most likely meant could be missing from its own hint:(
INTERACTIVE_BROKERS_BROKERAGE— 11 edits away — was not suggested.) The edit-distance threshold is replaced with Jaro-Winkler similarity (threshold 0.87), a prefix-favoring measure that keeps suffix extensions and, as a bonus, rejects the junk matches short names produced under the distance cutoff (e.g.PIIno longer suggests'min', 'pow', 'sin'alongside'PI').Both fleet-reported cases now produce the intended hints against real Lean types:
Algorithm selection. Two candidate replacements were evaluated over real member pools (590
QCAlgorithmmembers,BrokerageName,System.String,System.Math,DayOfWeek, plus the existing test fixtures): a token-based clause (split on_/camel humps, relate on shared tokens, keep Levenshtein for typos) and Jaro-Winkler. Both pass all 13 graded cases; Jaro-Winkler was chosen because it replaces the edit-distance clause instead of augmenting it, so it also fixes the short-name junk the token variant inherits, with less code:QCAlgorithm.set_account_typecc, co, a, c, tset_account_currencyset_account_currencyBrokerageName.InteractiveBrokersINTERACTIVE_BROKERS_FIXBrokerageName.INTERACTIVE_BROKERSString.lenghtlengthlengthlengthMath.PIIPI, min, pow, sinPI, min, pow, sinPIString.EmpyEMPTY, copyEMPTY, copyEMPTYQCAlgorithm.cashASI, asi, CKS, cks, CRSIASI, asi, CKS, cks, CRSIset_cashQCAlgorithm.market_ordrmarket_order, AR, ar, A, amarket_ordermarket_order, market_on_open_order, …Threshold margins at 0.87: all intended targets score ≥ 0.90; the trimmed noise sits ≤ 0.851. Substring containment is kept (gated) as a fallback for fragment lookups Jaro-Winkler's match window cannot see (
cash→set_cash), scored by coverage so such matches always rank below similarity matches. The per-type candidate cache, per-(type, name) hint memoization, kind filtering and the 5-suggestion cap are unchanged.Does this close any currently open issues?
No open issue in this repo; addresses the enum/member did-you-mean defects from QuantConnect/Agents#305 (improvement 1).
Any other comments?
Tests:
py -3.11 -m pytest --runtime netcore tests→ 459 passed, 1 failed (test_module.py::test_explicit_assembly_load, pre-existing environmental failure, reproduced on unmodified master), 23 skipped.dotnet test src/embed_tests/Python.EmbeddingTest.csproj -c Release --filter "FullyQualifiedName!~SetPythonPath"→ 971 passed, 0 failed.Note: #144 moves
LevenshteinDistanceinto the sameUtil.csthis PR adds the Jaro-Winkler helpers to (and this PR removes that method's ClassBase copy), so whichever lands second has a trivial both-append merge inUtil.csand a deletion conflict inClassBase.cs.Checklist
Check all those that are applicable and complete.
AUTHORSCHANGELOG