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

Change subject: xmlreader: Remove allrevisions and default to latest revision
......................................................................

xmlreader: Remove allrevisions and default to latest revision

The allrevisions parameter was deprecated in Pywikibot 9.0 and is
scheduled for removal in Pywikibot 12. Remove the argument and its
compatibility warnings, and use revisions='latest' as the default as
planned when the revisions selector was introduced.

Keep explicit first_found, earliest, and all selection. Document the
default change and extend the existing revision-selection test to
cover an omitted revisions argument using the multi-revision fixture.

Bug: T340804
Change-Id: If88d28459de2c89e8f6aec2353725ee8c1131649
---
M ROADMAP.rst
M pywikibot/xmlreader.py
M tests/xmlreader_tests.py
3 files changed, 15 insertions(+), 29 deletions(-)

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




diff --git a/ROADMAP.rst b/ROADMAP.rst
index 8c0bc33..1864c8f 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -19,6 +19,10 @@
 
 **Other breaking changes**

+* :class:`xmlreader.XmlDump` now defaults to ``revisions='latest'`` instead of
+  ``'first_found'``. Use ``revisions='first_found'`` explicitly to retain the
+  previous revision selection. (:phab:`T340804`)
+
 * Return insertion-ordered plain dictionaries for template parameters from
   :func:`textlib.extract_templates_and_params`,
   :func:`textlib.extract_templates_and_params_regex_simple`, and
@@ -47,8 +51,6 @@
   use ``-limit`` instead (:phab:`T128981`)
 * 9.0.0: The *content* parameter of :meth:`proofreadpage.IndexPage.page_gen` 
is deprecated and will be
   ignored (:phab:`T358635`)
-* 9.0.0: ``allrevisions`` parameter of :class:`xmlreader.XmlDump` is 
deprecated, use ``revisions`` instead
-  (:phab:`T340804`)


 Pending removal in Pywikibot 13
diff --git a/pywikibot/xmlreader.py b/pywikibot/xmlreader.py
index 3a4bb66..fbef835 100644
--- a/pywikibot/xmlreader.py
+++ b/pywikibot/xmlreader.py
@@ -30,7 +30,7 @@

 from collections.abc import Callable, Iterator

-from pywikibot.tools import issue_deprecation_warning, open_archive
+from pywikibot.tools import open_archive


 @dataclass
@@ -100,6 +100,10 @@
        `allrevisions` parameter is deprecated due to :phab:`T340804`,
        `revisions` parameter was introduced as replacement.
        `root` attribute was removed.
+    .. version-removed:: 12.0
+       The `allrevisions` parameter.
+    .. version-changed:: 12.0
+       The default for `revisions` is ``latest`` instead of ``first_found``.

     Usage example:

@@ -116,9 +120,6 @@
     Pear 188924
     >>>

-    :param allrevisions: boolean
-        If True, parse all revisions instead of only the latest one.
-        Default: False.
     :param on_error: a callable which is invoked within :meth:`parse`
         method when a ParseError occurs. The exception is passed to this
         callable. Otherwise the exception is raised.
@@ -127,16 +128,14 @@
         * `latest` (most recent revision, by largest `revisionid`)
         * `earliest` (first revision, by smallest `revisionid`)
         * `all` (all revisions for each page)
-        Default: `first_found`
+        Default: `latest`
     """

     def __init__(
         self,
         filename,
         *,
-        allrevisions: bool | str | None = None,
-        # when allrevisions removed, revisions can default to 'latest'
-        revisions: str = 'first_found',
+        revisions: str = 'latest',
         on_error: Callable[[ParseError], None] | None = None,
     ) -> None:
         """Initializer."""
@@ -150,20 +149,6 @@
             'all': self._parse_all,
         }

-        if allrevisions:
-            issue_deprecation_warning(
-                'allrevisions=True',
-                "revisions='all'",
-                since='9.0.0')
-            revisions = 'all'
-        elif revisions == 'first_found':
-            issue_deprecation_warning(
-                'allrevisions=False returns first revision found,'
-                " usually earliest. For most recent, use revisions='latest'. "
-                "For oldest, use revisions='earliest',"
-                "'allrevisions'",
-                since='9.0.0')
-
         if revisions not in self.rev_actions:
             actions = str(list(self.rev_actions)).strip('[]')
             raise ValueError(f"'revisions' must be one of {actions}.")
diff --git a/tests/xmlreader_tests.py b/tests/xmlreader_tests.py
index dfa7f33..3a6f462 100755
--- a/tests/xmlreader_tests.py
+++ b/tests/xmlreader_tests.py
@@ -11,7 +11,6 @@
 from contextlib import suppress

 from pywikibot import xmlreader
-from pywikibot.tools import suppress_warnings
 from tests import join_xml_data_path
 from tests.aspects import TestCase

@@ -42,16 +41,16 @@
         self.assertEqual('Pear', pages[0].title)

     def test_XmlDumpFoundRev(self) -> None:
-        """Test loading the first, earliest and latest revision."""
+        """Test explicit revision selection and the latest revision default."""
         tests = {
             'first_found': ('Automated conversion', '185185'),
             'earliest': ('Automated conversion', '185185'),
             'latest': ('sp', '188924'),
+            None: ('sp', '188924'),
         }
         for revisions, (comment, revid) in tests.items():
-            with suppress_warnings(
-                    r".+'allrevisions' is deprecated since release 9\.0\.0"):
-                pages = get_entries('article-pear.xml', revisions=revisions)
+            kwargs = {'revisions': revisions} if revisions else {}
+            pages = get_entries('article-pear.xml', **kwargs)
             with self.subTest(revisions=revisions):
                 self.assertLength(pages, 1)
                 page = pages[0]

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1361166?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: If88d28459de2c89e8f6aec2353725ee8c1131649
Gerrit-Change-Number: 1361166
Gerrit-PatchSet: 2
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