10000 gh-112205: Support docstring for `@getter` by corona10 · Pull Request #113160 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-112205: Support docstring for @getter #113160

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

Merged
merged 12 commits into from
Dec 20, 2023
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
Next Next commit
gh-112205: Support docstring for @getter
  • Loading branch information
corona10 committed Dec 15, 2023
commit e9c99499be2ebf284f2a0e9e25d4c47d5beecb31
13 changes: 8 additions & 5 deletions Lib/test/clinic.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -4956,11 +4956,14 @@ Test_meth_coexist_impl(TestObj *self)
Test.property
[clinic start generated code]*/

PyDoc_STRVAR(Test_property__doc__,
"");

#if defined(TEST_PROPERTY_GETSETDEF)
# undef TEST_PROPERTY_GETSETDEF
# define TEST_PROPERTY_GETSETDEF {"property", (getter)Test_property_get, (setter)Test_property_set, NULL},
# define TEST_PROPERTY_GETSETDEF {"property", (getter)Test_property_get, (setter)Test_property_set, Test_property__doc__},
#else
# define TEST_PROPERTY_GETSETDEF {"property", (getter)Test_property_get, NULL, NULL},
# define TEST_PROPERTY_GETSETDEF {"property", (getter)Test_property_get, NULL, Test_property__doc__},
#endif

static PyObject *
Expand All @@ -4974,7 +4977,7 @@ Test_property_get(TestObj *self, void *Py_UNUSED(context))

static PyObject *
Test_property_get_impl(TestObj *self)
/*[clinic end generated code: output=af8140b692e0e2f1 input=2d92b3449fbc7d2b]*/
/*[clinic end generated code: output=6066ef293041bb7f input=2d92b3449fbc7d2b]*/

/*[clinic input]
@setter
Expand All @@ -4983,7 +4986,7 @@ Test.property

#if defined(TEST_PROPERTY_GETSETDEF)
# undef TEST_PROPERTY_GETSETDEF
# define TEST_PROPERTY_GETSETDEF {"property", (getter)Test_property_get, (setter)Test_property_set, NULL},
# define TEST_PROPERTY_GETSETDEF {"property", (getter)Test_property_get, (setter)Test_property_set, Test_property__doc__},
#else
# define TEST_PROPERTY_GETSETDEF {"property", NULL, (setter)Test_property_set, NULL},
#endif
Expand All @@ -4999,7 +5002,7 @@ Test_property_set(TestObj *self, PyObject *value, void *Py_UNUSED(context))

static int
Test_property_set_impl(TestObj *self, PyObject *value)
/*[clinic end generated code: output=f3eba6487d7550e2 input=3bc3f46a23c83a88]*/
/*[clinic end generated code: output=06bfbaf593f8b62b input=3bc3f46a23c83a88]*/

/*[clinic input]
output push
Expand Down
15 changes: 15 additions & 0 deletions Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2221,6 +2221,21 @@ class Foo "" ""
expected_error = f"{annotation} method cannot define parameters"
self.expect_failure(block, expected_error)

def test_setter_docstring(self):
block = """
module foo
class Foo "" ""
@setter
Foo.property

foo

bar
[clinic start generated code]*/
"""
expected_error = "@setter can not set docstring"
self.expect_failure(block, expected_error)

def test_duplicate_getset(self):
annotations = ["@getter", "@setter"]
for annotation in annotations:
Expand Down
23 changes: 16 additions & 7 deletions Modules/_io/clinic/bufferedio.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 16 additions & 7 deletions Modules/_io/clinic/stringio.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 92 additions & 12 deletions Modules/_io/clinic/textio.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
0