Xqt submitted this change.

View Change

Approvals: Xqt: Verified; Looks good to me, approved
doc: adjust classproperty docstrings for Python 3.12 and below

Bug: T381279
Change-Id: I22706940b1fc4f8ab401313495ff923cc6e9a634
---
M pywikibot/tools/__init__.py
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 7375d0d..d36f52c 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -180,11 +180,19 @@
"""Initializer: hold the class method and documentation."""
self.method = cls_method
self.__annotations__ = self.method.__annotations__
- self.__doc__ = (':class:`classproperty<tools.classproperty>` '
- f'{self.method.__doc__}')
+ doc = self.method.__doc__
+ self.__doc__ = f':class:`classproperty<tools.classproperty>` {doc}'
+
rtype = self.__annotations__.get('return')
if rtype:
- self.__doc__ += f'\n\n:rtype: {rtype}'
+ lines = doc.splitlines()
+
+ if len(lines) > 2 and PYTHON_VERSION < (3, 13):
+ spaces = ' ' * re.search('[^ ]', lines[2]).start()
+ else:
+ spaces = ''
+
+ self.__doc__ += f'\n{spaces}:rtype: {rtype}'

def __get__(self, instance, owner):
"""Get the attribute of the owner class by its method."""

To view, visit change 1099734. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I22706940b1fc4f8ab401313495ff923cc6e9a634
Gerrit-Change-Number: 1099734
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot