-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
gh-104683: Argument Clinic: Refactor and simplify 'add docstring' states #107550
gh-104683: Argument Clinic: Refactor and simplify 'add docstring' states #107550
Conversation
…g' states Introduce docstring_append() helper, and use it for both parameter and function docstrings. Remove docstring fixup from do_post_block_processing_cleanup(); instead, make sure no fixup is needed.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
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.
Remove docstring fixup from
do_post_block_processing_cleanup(); instead, make sure no fixup is needed.
I think the fixup is still needed. If I apply this diff to your PR branch:
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -5577,6 +5577,11 @@ def do_post_block_processing_cleanup(self) -> None:
if no_parameter_after_star:
fail("Function " + self.function.name + " specifies '*' without any parameters afterwards.")
+ for name, value in self.function.parameters.items():
+ if not value:
+ continue
+ assert value.docstring == value.docstring.rstrip()
+
self.function.docstring = self.format_docstring()
Then the assertion fails in ClinicParserTest.test_function_docstring
:
======================================================================
FAIL: test_function_docstring (test.test_clinic.ClinicParserTest.test_function_docstring)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alexw\coding\cpython\Lib\test\test_clinic.py", line 632, in test_function_docstring
function = self.parse_function("""
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\cpython\Lib\test\test_clinic.py", line 1384, in parse_function
block = self.parse(text)
^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\cpython\Lib\test\test_clinic.py", line 1380, in parse
parser.parse(block)
File "C:\Users\alexw\coding\cpython\Tools\clinic\clinic.py", line 4612, in parse
self.do_post_block_processing_cleanup()
File "C:\Users\alexw\coding\cpython\Tools\clinic\clinic.py", line 5583, in do_post_block_processing_cleanup
assert value.docstring == value.docstring.rstrip()
AssertionError
----------------------------------------------------------------------
When you're done making the requested changes, leave the comment: |
The docstrings are further processed in |
Ugh, yes, I think you're right :) |
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.
Thank you! Looks good now the test's been added :)
See also the added test ;) |
Introduce docstring_append() helper, and use it for both parameter and
function docstrings. Remove docstring fixup from
do_post_block_processing_cleanup(); instead, make sure no fixup is needed.
Tools/clinic/
#104683