-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-133436: Correct error messages that incorrectly use "arguments" #133463
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
Conversation
| '*' ',' TYPE_COMMENT { RAISE_SYNTAX_ERROR("bare * has associated type comment") } | ||
| '*' param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "var-positional argument cannot have default value") } | ||
| '*' (param_no_default | ',') param_maybe_default* a='*' (param_no_default | ',') { | ||
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "* argument may appear only once") } | ||
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "* marker may appear only once") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked @picnixz suggestion though there may be an even better word?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo, "an asterisk may appear only once" is as clear as possible and will not cause any confusion in terms of terminology
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other error messages refer to /
as just /
and to *
as just *
. On other hand, * marker
can be confused with bare *
. So I think that it is better to use just *
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are more:
def f(/, *a, b): pass
^
SyntaxError: at least one argument must precede /
def f(**a, b): pass
^
SyntaxError: arguments cannot follow var-keyword argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More examples:
def f(/, a, /, b): pass
^
SyntaxError: at least one argument must precede /
def f(a, a): pass
^
SyntaxError: duplicate argument 'a' in function definition
| '*' ',' TYPE_COMMENT { RAISE_SYNTAX_ERROR("bare * has associated type comment") } | ||
| '*' param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "var-positional argument cannot have default value") } | ||
| '*' (param_no_default | ',') param_maybe_default* a='*' (param_no_default | ',') { | ||
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "* argument may appear only once") } | ||
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "* marker may appear only once") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other error messages refer to /
as just /
and to *
as just *
. On other hand, * marker
can be confused with bare *
. So I think that it is better to use just *
here.
I suggest to do all in one PR. I do not see semantic difference. There are other error messages that need corrections, see my examples. |
I'll close this one and the corresponding issue. We'll work with one issue and one PR instead. |
*
parameter's error messages sayargument
instead ofparameter
#133436