FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-107944: Improve error message for function calls with bad keyword arguments by pablogsal · Pull Request #107969 · python/cpython · GitHub

Repository navigation

gh-107944: Improve error message for function calls with bad keyword arguments - #107969

Merged
pablogsal merged 1 commit into
python:mainfrom
pablogsal:gh-107944
Aug 17, 2023
Merged

pablogsal merged 1 commit into
python:mainfrom
pablogsal:gh-107944

Conversation

pablogsal commented Aug 15, 2023 •
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

Comment thread Python/ceval.c
Py_DECREF(suggestion_keyword);
} else {
_PyErr_Format(tstate, PyExc_TypeError,
"%U() got an unexpected keyword argument '%S'",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Wouldn't it be a better UX if we included a list with all the possible keywords here? We could special-case it for cases where the list is smaller than X, in order to keep the output to a reasonable size.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think is better, but on the other hand, it would be a bunch of extra code (joining the list with commas + handling errors) so not sure if is worth the complexity. @rhettinger what do you think? (Note we are referring to the fallback message when we could not find the suggestion either because of errors or because there is nothing close).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

what do you think?

I think what you have now will suffice — only offer a suggestion when a plausible candidate can be found; otherwise, just note that the keyword argument doesn't match.

pablogsal requested a review from rhettinger August 15, 2023 10:22
pablogsal force-pushed the gh-107944 branch 2 times, most recently from 0c61952 to a1e2c35 Compare August 15, 2023 10:55
…yword arguments

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>

Copy link
Copy Markdown
Member Author

@lysnikolaou apart from the suggestion is everything else ok with you? (In that case, could you approve the PR?)

lysnikolaou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks good!!

pablogsal merged commit 75b3db8 into python:main Aug 17, 2023
pablogsal deleted the gh-107944 branch August 17, 2023 18:39
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL