jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1361167?usp=email )

Change subject: page: Remove deprecated main_authors method
......................................................................

page: Remove deprecated main_authors method

Page.main_authors was deprecated in Pywikibot 9.3 in favour of
authorship. Remove the wrapper and its obsolete onlynew argument
adapter for Pywikibot 12, together with the unused imports.

Update the shared support-check errors and existing test descriptions
to name authorship. Document the removal and retain historical mentions
as plain text rather than links to the removed method.

Change-Id: I6e16375aeccb4f0af022916f6846fd0aa1886823
---
M ROADMAP.rst
M pywikibot/page/_toolforge.py
M tests/wikiblame_tests.py
3 files changed, 14 insertions(+), 41 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/ROADMAP.rst b/ROADMAP.rst
index efc7191..c728534 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -16,6 +16,8 @@
   a boolean value for *bot*.
 * Remove the deprecated ``xmlreader.parseRestrictions`` alias; use
   :meth:`xmlreader.XmlDump.parse_restrictions` instead.
+* Remove ``Page.main_authors()``, deprecated since 9.3. Use
+  :meth:`Page.authorship()<page._toolforge.WikiBlameMixin.authorship>` instead.

 **Other breaking changes**

diff --git a/pywikibot/page/_toolforge.py b/pywikibot/page/_toolforge.py
index e29cd0a..c7f4238 100644
--- a/pywikibot/page/_toolforge.py
+++ b/pywikibot/page/_toolforge.py
@@ -9,7 +9,6 @@
 """
 from __future__ import annotations

-import collections
 import pickle
 import re
 import urllib.parse
@@ -19,7 +18,7 @@
 from warnings import warn

 import pywikibot
-from pywikibot.tools import deprecated, deprecated_args, remove_last_args
+from pywikibot.tools import remove_last_args


 class WikiBlameMixin:
@@ -36,47 +35,19 @@
         """Check if WikiHistory is supported."""
         if self.site.family.name != 'wikipedia':
             raise NotImplementedError(
-                'main_authors method is implemented for wikipedia family only')
+                'authorship method is implemented for wikipedia family only')

         if (code := self.site.code) not in self.WIKIBLAME_CODES:
             raise NotImplementedError(
-                f'main_authors method is not implemented for wikipedia:{code}')
+                f'authorship method is not implemented for wikipedia:{code}')

         if (ns := self.namespace()) not in (0, 4, 10, 12, 14, 100):
             raise NotImplementedError(
-                f'main_authors method is not implemented for {ns} namespace')
+                f'authorship method is not implemented for {ns} namespace')

         if not self.exists():
             raise pywikibot.exceptions.NoPageError(self)

-    @deprecated('authorship', since='9.3.0')
-    @deprecated_args(onlynew=None)  # since 9.2.0
-    def main_authors(self) -> collections.Counter[str, int]:
-        """Retrieve the 5 topmost main authors of an article.
-
-        Sample:
-
-        >>> import pywikibot
-        >>> site = pywikibot.Site('wikipedia:de')
-        >>> page = pywikibot.Page(site, 'Project:Pywikibot')
-        >>> auth = page.main_authors()  # doctest: +SKIP
-        >>> auth.most_common(1)  # doctest: +SKIP
-        [('DrTrigon', 37)]
-
-        .. version-deprecated:: 9.3
-           use :meth:`authorship` instead.
-        .. seealso:: :meth:`authorship` for further information
-
-        :return: Percentage of edits for each username
-
-        :raise NotImplementedError: unsupported site or unsupported
-            namespace.
-        :raise NoPageError: The page does not exist.
-        :raise ApiTimeoutError: WikiHistory timeout
-        """
-        return collections.Counter(
-            {user: int(cnt) for user, (_, cnt) in self.authorship(5).items()})
-
     @remove_last_args(['revid', 'date'])  # since 10.1.0
     def authorship(
         self,
@@ -105,7 +76,7 @@
            :attr:`WIKIBLAME_CODES` are supported.
         .. version-added:: 9.3
            XTools is used to retrieve authors. This method replaces
-           :meth:`main_authors`.
+           ``main_authors()``.
         .. version-changed:: 10.1
            WikiHistory is used to retrieve authors due to :phab:`T392694`.

@@ -118,7 +89,7 @@
               .. version-added:: 10.1

               - Implemented from version 7.7 until 9.2 (with
-                :meth:`main_authors` method) and from 10.1.
+                ``main_authors()`` method) and from 10.1.
               - Main, Project, Category and Template namespaces are
                 supported
               - Only 'als', 'bar', 'de', 'en', 'it', 'nds' and 'sco'
diff --git a/tests/wikiblame_tests.py b/tests/wikiblame_tests.py
index 8577afe..4a98e2c 100644
--- a/tests/wikiblame_tests.py
+++ b/tests/wikiblame_tests.py
@@ -22,7 +22,7 @@
     code = 'nds'

     def test_exceptions(self) -> None:
-        """Test that main_authors fails if page does not exist."""
+        """Test that authorship fails if page does not exist."""
         page = pywikibot.Page(self.site, 'Pywikibot')
         title = re.escape(page.title(as_link=True))
         with self.assertRaisesRegex(pywikibot.exceptions.NoPageError,
@@ -32,18 +32,18 @@
         page = pywikibot.Page(self.site, 'Diskuschoon:Wikipedia')
         with self.assertRaisesRegex(
             NotImplementedError,
-                'main_authors method is not implemented for Talk: namespace'):
+                'authorship method is not implemented for Talk: namespace'):
             page.authorship()

         page = pywikibot.Page(pywikibot.Site('wikipedia:nl'),
                               'Project:Pywikibot')
         with self.assertRaisesRegex(
             NotImplementedError,
-                'main_authors method is not implemented for wikipedia:nl'):
+                'authorship method is not implemented for wikipedia:nl'):
             page.authorship()

-    def test_main_authors(self) -> None:
-        """Test main_authors() method."""
+    def test_authorship(self) -> None:
+        """Test authorship() method."""
         page = pywikibot.Page(self.site, 'Python (Programmeerspraak)')
         auth = page.authorship(5)
         self.assertLessEqual(len(auth), 5)
@@ -54,7 +54,7 @@
         self.assertIsInstance(values[1], float)

     def test_restrictions(self) -> None:
-        """Test main_authors() method with restrictions."""
+        """Test authorship() method with restrictions."""
         page = pywikibot.Page(pywikibot.Site('wikipedia:en'), 'Python')
         auth = page.authorship(4, min_chars=100, min_pct=5.0)
         self.assertLessEqual(len(auth), 4)

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1361167?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: I6e16375aeccb4f0af022916f6846fd0aa1886823
Gerrit-Change-Number: 1361167
Gerrit-PatchSet: 3
Gerrit-Owner: Mahveotm <[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]

Reply via email to