Skip to content

Commit d2130ab

Browse files
Fix fixup code and add test
1 parent dc8f10d commit d2130ab

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

Lib/test/test_clinic.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,18 @@ def test_parameters_required_after_star(self):
14831483
with self.subTest(block=block):
14841484
self.expect_failure(block, err)
14851485

1486+
def test_parameters_required_after_depr_star(self):
1487+
dataset = (
1488+
"module foo\nfoo.bar\n * [from 3.14]",
1489+
"module foo\nfoo.bar\n * [from 3.14]\nDocstring here.",
1490+
"module foo\nfoo.bar\n this: int\n * [from 3.14]",
1491+
"module foo\nfoo.bar\n this: int\n * [from 3.14]\nDocstring.",
1492+
)
1493+
err = "Function 'foo.bar' specifies '* [from 3.14]' without any parameters afterwards."
1494+
for block in dataset:
1495+
with self.subTest(block=block):
1496+
self.expect_failure(block, err)
1497+
14861498
def test_depr_star_invalid_format_1(self):
14871499
block = """
14881500
module foo

Tools/clinic/clinic.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5729,12 +5729,10 @@ def check_remaining(
57295729
) -> None:
57305730
assert isinstance(self.function, Function)
57315731

5732-
if values := self.function.parameters.values():
5733-
last_param = next(reversed(values))
5734-
no_param_after_symbol = condition(last_param)
5735-
else:
5736-
no_param_after_symbol = True
5737-
if no_param_after_symbol:
5732+
values = self.function.parameters.values()
5733+
assert values
5734+
last_param = next(reversed(values))
5735+
if condition(last_param):
57385736
fname = self.function.full_name
57395737
fail(f"Function {fname!r} specifies {symbol!r} "
57405738
"without any parameters afterwards.", line_number=lineno)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy