Xqt has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1099734?usp=email )
Change subject: doc: adjust classproperty docstrings for Python 3.12 and below
......................................................................
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(-)
Approvals:
Xqt: Verified; Looks good to me, approved
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
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1099734?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I22706940b1fc4f8ab401313495ff923cc6e9a634
Gerrit-Change-Number: 1099734
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]