Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address code review
  • Loading branch information
corona10 committed Dec 19, 2023
commit c1b6901f528fba88cfe052aa248aa2fe529a5593
2 changes: 1 addition & 1 deletion Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2233,7 +2233,7 @@ class Foo "" ""
bar
[clinic start generated code]*/
"""
expected_error = "@setter can not set docstring"
expected_error = "docstrings are only supported for @getter, not @setter"
self.expect_failure(block, expected_error)

def test_duplicate_getset(self):
Expand Down
12 changes: 7 additions & 5 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6280,6 +6280,7 @@ def format_docstring_signature(
if self.forced_text_signature:
add(self.forced_text_signature)
elif f.kind in {GETTER, SETTER}:
# @getter and @setter do not need signatures like a method or a function.
return ''
Comment thread
corona10 marked this conversation as resolved.
else:
add('(')
Expand Down Expand Up @@ -6453,11 +6454,12 @@ def format_docstring_parameters(params: list[Parameter]) -> str:
def format_docstring(self) -> str:
assert self.function is not None
f = self.function
if f.kind.new_or_init and not f.docstring:
# don't render a docstring at all, no signature, nothing.
return f.docstring
if f.kind in {GETTER, SETTER} and not f.docstring:
# don't render a docstring at all, no signature, nothing.
k = f.kind
if (k.new_or_init or k in {GETTER, SETTER}) and not f.docstring:
# If the following methods have a empty docstring,
# Do not render a docstring at all, no signature, nothing.
# 1. __init__ / __new__
# 2. @getter / @setter properties
return f.docstring

# Enforce the summary line!
Expand Down