Xqt has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1203208?usp=email )

Change subject: cleanup: remove deprecated code parts and update ROADMAP.rst
......................................................................

cleanup: remove deprecated code parts and update ROADMAP.rst

- remove dropdelay and releasepid properties from Throttle
- update textlib.replaceLanguageLinks and textlib.replaceCategoryLinks
- simplify TimeStripper
- remove NoPageError dependency of exceptions.NoSiteLinkError
- update APISite.page_from_repository()
- update ROADMAP.rst

Bug: T396368
Change-Id: I4b91fde991a4f786408c70b8f0b4a530fb61909b
---
M ROADMAP.rst
M pywikibot/exceptions.py
M pywikibot/site/_apisite.py
M pywikibot/textlib.py
M pywikibot/throttle.py
5 files changed, 33 insertions(+), 107 deletions(-)

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




diff --git a/ROADMAP.rst b/ROADMAP.rst
index 830c344..62225a1 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -12,6 +12,17 @@

 **Code cleanups**

+* The inheritance of the :exc:`exceptions.NoSiteLinkError` exception from
+  :exc:`exceptions.NoPageError` was removed
+* The *dropdelay* and *releasepid* attributes of the 
:class:`throttle.Throttle` class was
+  removed in favour of the *expiry* class attribute.
+* The regex attributes ``ptimeR``, ``ptimeznR``, ``pyearR``, ``pmonthR``, and 
``pdayR`` of
+  the :class:`textlib.TimeStripper` class was removed in favour of the 
``patterns`` attribute,
+  which is a :class:`textlib.TimeStripperPatterns` object.
+* The ``groups`` attribute of the :class:`textlib.TimeStripper` was removed in 
favour
+  of the :data:`textlib.TIMEGROUPS` constant.
+* The ``addOnly`` parameter in the :func:`textlib.replaceLanguageLinks` and
+  :func:`textlib.replaceCategoryLinks` was dropped in favour of ``add_only``.
 * ``load_tokens`` method of 
:class:`TokenWallet<pywikibot.site._tokenwallet.TokenWallet>` was
   removed; ``clear`` method can be used instead.
 * No longer support legacy API tokens of MediaWiki 1.23 and older. 
(:phab:`270380`, :phab:`306637`)
@@ -74,17 +85,6 @@
 * 10.7.0: Dysfunctional :meth:`APISite.alllinks()
   <pywikibot.site._generators.GeneratorsMixin.alllinks>` will be removed.
   (:phab:`T359427`, :phab:`T407708`)
-* 8.4.0: The *dropdelay* and *releasepid* attributes of the 
:class:`throttle.Throttle` class will be
-  removed in favour of the *expiry* class attribute
-* 8.1.0: The inheritance of the :exc:`exceptions.NoSiteLinkError` exception 
from
-  :exc:`exceptions.NoPageError` will be removed
-* 8.0.0: The ``addOnly`` parameter in the :func:`textlib.replaceLanguageLinks` 
and
-  :func:`textlib.replaceCategoryLinks` functions is deprecated in favour of 
``add_only``
-* 8.0.0: The regex attributes ``ptimeR``, ``ptimeznR``, ``pyearR``, 
``pmonthR``, and ``pdayR`` of
-  the :class:`textlib.TimeStripper` class are deprecated in favour of the 
``patterns`` attribute,
-  which is a :class:`textlib.TimeStripperPatterns` object
-* 8.0.0: The ``groups`` attribute of the :class:`textlib.TimeStripper` class 
is deprecated in favour
-  of the :data:`textlib.TIMEGROUPS` constant


 Pending removal in Pywikibot 12
diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index fafa883..ac14c12 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -408,20 +408,23 @@
         super().__init__(page)


-class NoSiteLinkError(PageLoadRelatedError, NoPageError):
+class NoSiteLinkError(PageLoadRelatedError):

     """ItemPage has no sitelink to the given site.

     .. versionadded:: 8.1
     .. deprecated:: 8.1
-       :exc:`NoPageError` dependency.
+       This exception depends on :exc:`NoPageError` but it will be
+       removed.
+    .. versionremoved:: 11.0
+       Dependency on :exc:`NoPageError` was removed.
     """

     def __init__(self, page: pywikibot.page.ItemPage, dbname: str) -> None:
         """Initializer.

-        :param page: ItemPage that caused the exception
-        :param dbname: site identifier of the queried sitelink
+        :param page: ItemPage that caused the exception.
+        :param dbname: site identifier of the queried sitelink.
         """
         self.message = f'Item {{}} has no sitelink to {dbname!r}'
         super().__init__(page)
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index a6344d1..8664488 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -37,6 +37,7 @@
     LockedPageError,
     NoCreateError,
     NoPageError,
+    NoSiteLinkError,
     NoUsernameError,
     PageCreatedConflictError,
     PageDeletedConflictError,
@@ -1373,13 +1374,16 @@
 
         repo = self.data_repository()
         dp = pywikibot.ItemPage(repo, item)
+
         try:
             page_title = dp.getSitelink(self)
-        except NoPageError:
+        except (NoPageError, NoSiteLinkError):
             return None
+
         page = pywikibot.Page(self, page_title)
         if page.namespace() == Namespace.CATEGORY:
             page = pywikibot.Category(page)
+
         return page
 
     def nice_get_address(self, title: str) -> str:
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 115c19f..e9267ee 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -10,7 +10,7 @@
 import re
 import sys
 from collections import OrderedDict
-from collections.abc import Callable, Container, Iterable, Sequence
+from collections.abc import Callable, Container, Iterable, Mapping, Sequence
 from contextlib import closing, suppress
 from dataclasses import dataclass
 from html.parser import HTMLParser
@@ -21,13 +21,7 @@
 from pywikibot.exceptions import InvalidTitleError, SiteDefinitionError
 from pywikibot.family import Family
 from pywikibot.time import TZoneFixedOffset
-from pywikibot.tools import (
-    ModuleDeprecationWrapper,
-    deprecated,
-    deprecated_args,
-    first_lower,
-    first_upper,
-)
+from pywikibot.tools import ModuleDeprecationWrapper, first_lower, first_upper
 from pywikibot.userinterfaces.transliteration import NON_ASCII_DIGITS


@@ -1509,15 +1503,18 @@
     return removeLanguageLinks(text, site, marker)


-@deprecated_args(addOnly='add_only')  # since 8.0
 def replaceLanguageLinks(oldtext: str,
-                         new: dict,
+                         new: Mapping[pywikibot.site.BaseSite,
+                                      pywikibot.Page | pywikibot.Link],
                          site: pywikibot.site.BaseSite | None = None,
                          add_only: bool = False,
                          template: bool = False,
                          template_subpage: bool = False) -> str:
     """Replace inter-language links in the text with a new set of links.

+    .. versionchanged:: 8.0
+       *addOnly* was renamed to *add_only*.
+
     :param oldtext: The text that needs to be modified.
     :param new: A dict with the Site objects as keys, and Page or Link
         objects as values (i.e., just like the dict returned by
@@ -1840,13 +1837,15 @@
     return text


-@deprecated_args(addOnly='add_only')  # since 8.0
 def replaceCategoryLinks(oldtext: str,
                          new: Iterable,
                          site: pywikibot.site.BaseSite | None = None,
                          add_only: bool = False) -> str:
     """Replace all existing category links with new category links.

+    .. versionchanged:: 8.0
+       *addOnly* was renamed to *add_only*.
+
     :param oldtext: The text that needs to be replaced.
     :param new: Should be a list of Category objects or strings
         which can be either the raw name or ``[[Category:..]]``.
@@ -2286,66 +2285,6 @@
         self.tzinfo = TZoneFixedOffset(self.site.siteinfo['timeoffset'],
                                        self.site.siteinfo['timezone'])

-    @property
-    @deprecated('patterns.time', since='8.0.0')
-    def ptimeR(self):
-        """Deprecated time pattern attribute.
-
-        .. deprecated:: 8.0
-           use pattern.time instead
-        """
-        return self.patterns.time
-
-    @property
-    @deprecated('patterns.tzinfo', since='8.0.0')
-    def ptimeznR(self):
-        """Deprecated tzinfo pattern attribute.
-
-        .. deprecated:: 8.0
-           use patterns.tzinfo instead
-        """
-        return self.patterns.tzinfo
-
-    @property
-    @deprecated('patterns.year', since='8.0.0')
-    def pyearR(self):
-        """Deprecated year pattern attribute.
-
-        .. deprecated:: 8.0
-           use patterns.year instead
-        """
-        return self.patterns.year
-
-    @property
-    @deprecated('patterns.month', since='8.0.0')
-    def pmonthR(self):
-        """Deprecated month pattern attribute.
-
-        .. deprecated:: 8.0
-           use patterns.month instead
-        """
-        return self.patterns.month
-
-    @property
-    @deprecated('patterns.day', since='8.0.0')
-    def pdayR(self):
-        """Deprecated day pattern attribute.
-
-        .. deprecated:: 8.0
-           use patterns.day instead
-        """
-        return self.patterns.day
-
-    @property
-    @deprecated('textlib.TIMEGROUPS', since='8.0.0')
-    def groups(self):
-        """Deprecated groups attribute.
-
-        .. deprecated:: 8.0
-           use textlib.TIMEGROUPS instead
-        """
-        return TIMEGROUPS
-
     def _last_match_and_replace(self,
                                 txt: str,
                                 pat) -> tuple[str, re.Match[str] | None]:
diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py
index a106eaf..53ed103 100644
--- a/pywikibot/throttle.py
+++ b/pywikibot/throttle.py
@@ -115,26 +115,6 @@
            compatibility.
         """

-    @property
-    @deprecated('expiry', since='8.4.0')
-    def dropdelay(self):
-        """Ignore processes that have not made a check in this many seconds.
-
-        .. deprecated:: 8.4
-           use *expiry* instead.
-        """
-        return self.expiry
-
-    @property
-    @deprecated('expiry', since='8.4.0')
-    def releasepid(self):
-        """Free the process id after this many seconds.
-
-        .. deprecated:: 8.4
-           use *expiry* instead.
-        """
-        return self.expiry
-
     @staticmethod
     def _module_hash(module=None) -> str:
         """Convert called module name to a hash."""

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

Reply via email to