-
-
Notifications
You must be signed in to change notification settings - Fork 33k
gh-64490: Tweak AC implementation for **kwds
#139133
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -358,27 +358,13 @@ def test_vararg_after_star(self): | |
self.expect_failure(block, err, lineno=6) | ||
|
||
def test_double_star_after_var_keyword(self): | ||
err = "Function 'my_test_func' has an invalid parameter declaration (**kwargs?): '**kwds: dict'" | ||
err = "parameters cannot follow var-keyword parameter: 'invalid_arg: object'" | ||
block = """ | ||
/*[clinic input] | ||
my_test_func | ||
|
||
pos_arg: object | ||
**kwds: dict | ||
** | ||
[clinic start generated code]*/ | ||
""" | ||
self.expect_failure(block, err, lineno=5) | ||
|
||
def test_var_keyword_after_star(self): | ||
err = "Function 'my_test_func' has an invalid parameter declaration: '**'" | ||
block = """ | ||
/*[clinic input] | ||
my_test_func | ||
|
||
pos_arg: object | ||
** | ||
**kwds: dict | ||
invalid_arg: object | ||
[clinic start generated code]*/ | ||
""" | ||
self.expect_failure(block, err, lineno=5) | ||
|
@@ -1644,11 +1630,6 @@ def test_disallowed_grouping__must_be_position_only(self): | |
[ | ||
a: object | ||
] | ||
""", """ | ||
with_kwds | ||
[ | ||
**kwds: dict | ||
] | ||
Comment on lines
-1647
to
-1651
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add also a test for var-positional?
If it is an error and has not yet been tested. If it is an error, and the error message is the same as for keyword arguments here, then it would be reasonable to make the error message for var-keyword the same. Otherwise we can leave a discrepancy. |
||
""") | ||
err = ( | ||
"You cannot use optional groups ('[' and ']') unless all " | ||
|
@@ -2036,38 +2017,40 @@ def test_slash_after_var_keyword(self): | |
block = """ | ||
module foo | ||
foo.bar | ||
x: int | ||
y: int | ||
**kwds: dict | ||
z: int | ||
/ | ||
""" | ||
err = "Function 'bar' has an invalid parameter declaration (**kwargs?): '**kwds: dict'" | ||
err = "parameters cannot follow var-keyword parameter: '/'" | ||
self.expect_failure(block, err) | ||
|
||
def test_star_after_var_keyword(self): | ||
block = """ | ||
module foo | ||
foo.bar | ||
x: int | ||
y: int | ||
**kwds: dict | ||
z: int | ||
* | ||
""" | ||
err = "Function 'bar' has an invalid parameter declaration (**kwargs?): '**kwds: dict'" | ||
err = "parameters cannot follow var-keyword parameter: '*'" | ||
self.expect_failure(block, err) | ||
|
||
def test_parameter_after_var_keyword(self): | ||
block = """ | ||
module foo | ||
foo.bar | ||
x: int | ||
y: int | ||
**kwds: dict | ||
z: int | ||
""" | ||
err = "Function 'bar' has an invalid parameter declaration (**kwargs?): '**kwds: dict'" | ||
err = "parameters cannot follow var-keyword parameter: 'z: int'" | ||
self.expect_failure(block, err) | ||
|
||
def test_group_with_var_keyword(self): | ||
block = """ | ||
with_kwds | ||
[ | ||
**kwds: dict | ||
] | ||
""" | ||
err = "parameters cannot follow var-keyword parameter: ']'" | ||
self.expect_failure(block, err) | ||
|
||
def test_depr_star_must_come_after_slash(self): | ||
|
@@ -2159,7 +2142,7 @@ def test_parameters_no_more_than_one_vararg(self): | |
self.expect_failure(block, err, lineno=3) | ||
|
||
def test_parameters_no_more_than_one_var_keyword(self): | ||
err = "Encountered parameter line when not expecting parameters: **var_keyword_2: dict" | ||
err = "parameters cannot follow var-keyword parameter: '**var_keyword_2: dict'" | ||
block = """ | ||
module foo | ||
foo.bar | ||
|
@@ -2714,7 +2697,9 @@ def test_var_keyword_with_pos_or_kw(self): | |
x: int | ||
**kwds: dict | ||
""" | ||
err = "Function 'bar' has an invalid parameter declaration (**kwargs?): '**kwds: dict'" | ||
err = ("Function 'bar' uses a var-keyword parameter and other " | ||
"non-positional parameters, which Argument Clinic does " | ||
"not currently support: '**kwds: dict'") | ||
self.expect_failure(block, err) | ||
|
||
def test_var_keyword_with_kw_only(self): | ||
|
@@ -2727,7 +2712,9 @@ def test_var_keyword_with_kw_only(self): | |
y: int | ||
**kwds: dict | ||
""" | ||
err = "Function 'bar' has an invalid parameter declaration (**kwargs?): '**kwds: dict'" | ||
err = ("Function 'bar' uses a var-keyword parameter and other " | ||
"non-positional parameters, which Argument Clinic does " | ||
"not currently support: '**kwds: dict'") | ||
self.expect_failure(block, err) | ||
|
||
def test_var_keyword_with_pos_or_kw_and_kw_only(self): | ||
|
@@ -2741,7 +2728,9 @@ def test_var_keyword_with_pos_or_kw_and_kw_only(self): | |
z: int | ||
**kwds: dict | ||
""" | ||
err = "Function 'bar' has an invalid parameter declaration (**kwargs?): '**kwds: dict'" | ||
err = ("Function 'bar' uses a var-keyword parameter and other " | ||
"non-positional parameters, which Argument Clinic does " | ||
"not currently support: '**kwds: dict'") | ||
self.expect_failure(block, err) | ||
|
||
def test_allow_negative_accepted_by_py_ssize_t_converter_only(self): | ||
|
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.
Should be renamed.
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.
And, is there a test for a single
**
without name?