8000 gh-115077: Make some Argument Clinic error messages more helpful by erlend-aasland · Pull Request #115078 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-115077: Make some Argument Clinic error messages more helpful #115078

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

erlend-aasland
Copy link
Contributor
@erlend-aasland erlend-aasland commented Feb 6, 2024

@@ -5019,7 +5021,8 @@ def at_classmethod(self) -> None:

def at_critical_section(self, *args: str) -> None:
if len(args) > 2:
fail("Up to 2 critical section variables are supported")
fail("Only 2 critical section variables are supported; "
f"{len(args)} was given")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
f"{len(args)} was given")
f"{len(args)} were given")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps also print them out?

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
@erlend-aasland
Copy link
Contributor Author

@sobolevn, feel free to contribute to this branch/PR.

Comment on lines 838 to 839
fail("Cannot specify multiple varargs; "
f"'*{parameters[vararg].name}' was already provided as parameter {vararg+1}")
Copy link
Member
@serhiy-storchaka serhiy-storchaka Feb 6, 2024

Choose a reason for hiding this comment

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

You refer to the same parameter by the name and the number.
But the conflict is between two varargs parameters[vararg].name (number vararg+1) and p.name (number i).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps the number is not needed. I agree it is better if we refer to both parameters by name.

@erlend-aasland
Copy link
Contributor Author

Perhaps 94e082e is overdoing it.

@erlend-aasland
Copy link
Contributor Author

I'll have to start this branch over again; closing.

@erlend-aasland erlend-aasland deleted the clinic/better-error-messages branch October 15, 2024 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0