Skip to content

Commit 2c25bd8

Browse files
authored
gh-106368: Argument clinic: improve coverage for self.valid_line() calls (#107641)
1 parent 904b531 commit 2c25bd8

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

Lib/test/test_clinic.py

+32
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,38 @@ def test_explicit_parameters_in_docstring(self):
10571057
Okay, we're done here.
10581058
""")
10591059

1060+
def test_docstring_with_comments(self):
1061+
function = self.parse_function(dedent("""
1062+
module foo
1063+
foo.bar
1064+
x: int
1065+
# We're about to have
1066+
# the documentation for x.
1067+
Documentation for x.
1068+
# We've just had
1069+
# the documentation for x.
1070+
y: int
1071+
1072+
# We're about to have
1073+
# the documentation for foo.
1074+
This is the documentation for foo.
1075+
# We've just had
1076+
# the documentation for foo.
1077+
1078+
Okay, we're done here.
1079+
"""))
1080+
self.checkDocstring(function, """
1081+
bar($module, /, x, y)
1082+
--
1083+
1084+
This is the documentation for foo.
1085+
1086+
x
1087+
Documentation for x.
1088+
1089+
Okay, we're done here.
1090+
""")
1091+
10601092
def test_parser_regression_special_character_in_parameter_column_of_docstring_first_line(self):
10611093
function = self.parse_function(dedent("""
10621094
module os

Tools/clinic/clinic.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -4685,9 +4685,7 @@ def state_modulename_name(self, line: str) -> None:
46854685
# this line is permitted to start with whitespace.
46864686
# we'll call this number of spaces F (for "function").
46874687

4688-
if not self.valid_line(line):
4689-
return
4690-
4688+
assert self.valid_line(line)
46914689
self.indent.infer(line)
46924690

46934691
# are we cloning?

0 commit comments

Comments
 (0)