-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-95065: Add Argument Clinic support for deprecating positional use of parameters #95151
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
Changes from 43 commits
9196162
6a8c14f
457d38a
3687748
9c81ae1
a5734d6
1e9fd55
93e0745
6bde63d
bb619a5
d85475e
68f8ed9
ca496b4
fe77d5f
de9e661
3701b41
a149a7b
e9ad211
0fcad58
efb1fba
3d8164f
43cec6c
075cf67
13104e8
dc22c91
7864dcb
fbed52f
222c3bb
2abe7a3
4c0ec79
35fbe80
ccf8df8
4db3c8d
43af475
5074495
ce5cd92
c2cfc80
4dc8241
b2c8f34
5f181c7
9eab8f7
25aa23c
6624e8f
46924a7
2e72b66
cbbcf1a
f82be40
a76d63c
e5bbd7b
c981efa
821124e
aa1b85d
44af850
01f17f9
e6860bc
71a8750
e6886f0
480a29f
a3cf43a
5151e62
b98aab3
eeb8187
6c6dd10
ddd319b
47a8979
02eba96
fa77489
87a7f20
f36bc05
5e65020
f1f311a
83de0b8
b10dc9c
c4ba025
c875d60
cdd927c
f0847bc
ce8db9a
0dff20c
b45d845
d2330c6
622b556
e71fbe1
c4141f0
87e50c7
6e9e7b4
bde0f90
8e9ea05
8324510
2e4d64f
52e7078
8a39ffb
dc8f10d
d2130ab
b21bc32
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 |
---|---|---|
|
@@ -948,6 +948,72 @@ def test_parameters_required_after_star(self): | |
out = self.parse_function_should_fail(block) | ||
self.assertIn(msg, out) | ||
|
||
def test_depr_star_invalid_format_1(self): | ||
out = self.parse_function_should_fail(""" | ||
module foo | ||
foo.bar | ||
this: int | ||
* [from 3] | ||
erlend-aasland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Docstring. | ||
""") | ||
expected = ( | ||
"Error on line 0:\n" | ||
"Function 'bar': '* [from ...]' format expected to be " | ||
"'<major.minor>', where 'major' and 'minor' are digits.\n" | ||
) | ||
self.assertEqual(out, expected) | ||
|
||
def test_depr_star_invalid_format_2(self): | ||
out = self.parse_function_should_fail(""" | ||
module foo | ||
foo.bar | ||
this: int | ||
* [from a.b] | ||
Docstring. | ||
""") | ||
expected = ( | ||
"Error on line 0:\n" | ||
"Function 'bar', '* [from <major.minor>]': " | ||
"'major' and 'minor' must be digits, not 'a' and 'b'\n" | ||
) | ||
self.assertEqual(out, expected) | ||
|
||
def test_parameters_required_after_depr_star(self): | ||
out = self.parse_function_should_fail(""" | ||
module foo | ||
foo.bar | ||
this: int | ||
* [from 3.14] | ||
Docstring. | ||
""") | ||
msg = "Function bar specifies '* [from ...]' without any parameters afterwards." | ||
self.assertIn(msg, out) | ||
|
||
def test_depr_star_must_come_before_star(self): | ||
out = self.parse_function_should_fail(""" | ||
module foo | ||
foo.bar | ||
this: int | ||
* | ||
* [from 3.14] | ||
Docstring. | ||
""") | ||
msg = "Function 'bar': '* [from ...]' must come before '*'" | ||
self.assertIn(msg, out) | ||
|
||
def test_duplicate_depr_star(self): | ||
out = self.parse_function_should_fail(""" | ||
module foo | ||
foo.bar | ||
a: int | ||
* [from 3.14] | ||
erlend-aasland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* [from 3.14] | ||
b: int | ||
Docstring. | ||
""") | ||
msg = "Function 'bar' uses '[from ...]' more than once." | ||
self.assertIn(msg, out) | ||
|
||
def test_single_slash(self): | ||
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. I think that we are missing the deprecation warning check here. Calling 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. It seems we could reuse some of the pegen test support code (see Tools/peg_generator/pegen, 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. There are two scenarios we want to test:
I suggest we start with the former. The latter would be nice to have, but it requires more invasive changes, so I suggest we do that in separate PRs post this PR. |
||
out = self.parse_function_should_fail(""" | ||
module foo | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Add Argument Clinic support for deprecating positional use of optional | ||
parameters. Patch by Erlend E. Aasland. |
Uh oh!
There was an error while loading. Please reload this page.