[Python-checkins] gh-106368: Argument clinic: improve coverage for `self.valid_line()` calls (#107641)

AlexWaygood webhook-mailer at python.org
Fri Aug 4 15:41:08 EDT 2023


https://github.com/python/cpython/commit/2c25bd82f46df72c89ca5bca10eaa06137ab8290
commit: 2c25bd82f46df72c89ca5bca10eaa06137ab8290
branch: main
author: Alex Waygood <Alex.Waygood at Gmail.com>
committer: AlexWaygood <Alex.Waygood at Gmail.com>
date: 2023-08-04T20:41:04+01:00
summary:

gh-106368: Argument clinic: improve coverage for `self.valid_line()` calls (#107641)

files:
M Lib/test/test_clinic.py
M Tools/clinic/clinic.py

diff --git a/Lib/test/test_clinic.py b/Lib/test/test_clinic.py
index dd17d02519bfa..84b6a193ecf91 100644
--- a/Lib/test/test_clinic.py
+++ b/Lib/test/test_clinic.py
@@ -1057,6 +1057,38 @@ def test_explicit_parameters_in_docstring(self):
             Okay, we're done here.
         """)
 
+    def test_docstring_with_comments(self):
+        function = self.parse_function(dedent("""
+            module foo
+            foo.bar
+              x: int
+                 # We're about to have
+                 # the documentation for x.
+                 Documentation for x.
+                 # We've just had
+                 # the documentation for x.
+              y: int
+
+            # We're about to have
+            # the documentation for foo.
+            This is the documentation for foo.
+            # We've just had
+            # the documentation for foo.
+
+            Okay, we're done here.
+        """))
+        self.checkDocstring(function, """
+            bar($module, /, x, y)
+            --
+
+            This is the documentation for foo.
+
+              x
+                Documentation for x.
+
+            Okay, we're done here.
+        """)
+
     def test_parser_regression_special_character_in_parameter_column_of_docstring_first_line(self):
         function = self.parse_function(dedent("""
             module os
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 917f1bfeb1d25..7fbae1e0d870a 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -4685,9 +4685,7 @@ def state_modulename_name(self, line: str) -> None:
         # this line is permitted to start with whitespace.
         # we'll call this number of spaces F (for "function").
 
-        if not self.valid_line(line):
-            return
-
+        assert self.valid_line(line)
         self.indent.infer(line)
 
         # are we cloning?



More information about the Python-checkins mailing list