fix: deduplicate get_close_matches suggestions and support iterator targets#5664
Open
eeshsaxena wants to merge 1 commit into
Open
fix: deduplicate get_close_matches suggestions and support iterator targets#5664eeshsaxena wants to merge 1 commit into
eeshsaxena wants to merge 1 commit into
Conversation
…argets When get_close_matches received a list of inputs, targets matched by more than one input were repeated in the returned suggestions (surfaced in the 'did you mean' text of PipelineError). It also called list(targets) once per input, so a one-shot iterable passed as targets would be exhausted after the first input. Materialize targets once and deduplicate matches while preserving order. Signed-off-by: eeshsaxena <eeshsaxena@gmail.com>
merelcht
requested review from
ankatiyar and
ravi-kumar-pilla
and removed request for
merelcht
July 16, 2026 08:19
ankatiyar
reviewed
Jul 17, 2026
| def test_list_input_accepts_one_shot_iterator_targets(self): | ||
| # `targets` is typed as an Iterable; a generator must not be exhausted | ||
| # after matching the first input string. | ||
| targets = (name for name in ["data_science", "data_engineering"]) |
Contributor
There was a problem hiding this comment.
Suggested change
| targets = (name for name in ["data_science", "data_engineering"]) | |
| targets = iter(["data_science", "data_engineering"]) |
ankatiyar
approved these changes
Jul 17, 2026
ankatiyar
left a comment
Contributor
There was a problem hiding this comment.
Thanks @eeshsaxena LGTM with a minor suggestion to make the test intent clearer
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.
Description
get_close_matches(inkedro/utils.py) has two issues when it receives a list of inputs:Duplicate suggestions. Matches are collected per input and concatenated, so a target matched by more than one input is repeated. This surfaces in the user-facing "did you mean one of these instead: ..." text of
PipelineError(via_validate_datasets_existinkedro/pipeline/pipeline.py). For example:targetsiterable can be exhausted.targetsis typed asIterable[str], butlist(targets)was called once per input inside the loop. A one-shot iterable (e.g. a generator) is consumed on the first input, so later inputs match against an empty list and silently return nothing.Development notes
targets = list(targets)once, before iterating the inputs.strandlistinput handling; single-string behaviour is unchanged (a singledifflib.get_close_matchescall already returns unique, score-ordered results).Testing:
TestGetCloseMatchesintests/test_utils.py: one asserting shared matches are deduplicated, one passing a generator astargets. Both fail onmainand pass with this change; the existing string/list tests still pass (pytest tests/test_utils.py -k GetCloseMatches-> 4 passed).RELEASE.mdentry under "Bug fixes and other changes".An AI assistant helped spot and implement this; I reviewed the change and ran the tests locally.
Checklist
RELEASE.mdfile