Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Include close matches in error message when key not found#30001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
dstansby wants to merge2 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromdstansby:close-matches

Conversation

dstansby
Copy link
Member

This is an attempt to resurrect#28115, but make it more general so we can emit helpful error messages when keys aren't found.

@dstansbydstansby changed the titleInclude close matches when key not foundInclude close matches in error message when key not foundMay 2, 2025
@dstansbydstansbyforce-pushed theclose-matches branch 2 times, most recently frome92707c to3f98b36CompareMay 3, 2025 17:20
@dstansbydstansby marked this pull request as ready for reviewMay 3, 2025 18:53
@@ -174,12 +175,21 @@ def check_shape(shape, /, **kwargs):
)


def check_getitem(mapping, /, **kwargs):
def check_getitem(
mapping, /, _suggest_close_matches=False, _error_cls=ValueError, **kwargs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Would it make sense the make this depend on the number of elements by default? Suggest if there are more than N keys, otherwise list all. (Choose N somewhere between 5 and 10).

Maybe even don't make this configurable (YAGNI). I feel the automatic decision depending on the number of elements may be all we ever need and we don't need to bother with deciding on the option per call site.

We could always change later because this is private.

story645 and dstansby reacted with thumbs up emoji
@tacaswell
Copy link
Member

Where the discussion in#28115 got stalled is over using difflib or vendoring a copy of Levenstien distance with a question of how different the results are (and then I did not have time to answer that question). Do we want to resume that discussion or just usedifflib and move on?

I think either way getting close matches is better than the current state of things and contra my previous comments I'm in favor of using difflib and changing the algorithm later if it is a problem (I'm not going to consider the guessed "did you mean..." list to be something we need to maintain API stability on!).

timhoffm reacted with thumbs up emoji

@dstansbydstansby marked this pull request as draftMay 5, 2025 17:18
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic left review comments

@timhoffmtimhoffmtimhoffm left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Projects
None yet
Milestone
v3.11.0
Development

Successfully merging this pull request may close these issues.

4 participants
@dstansby@tacaswell@QuLogic@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp