jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1201738?usp=email )
Change subject: cleanup: remove deprecated code parts and update ROADMAP.rst
......................................................................
cleanup: remove deprecated code parts and update ROADMAP.rst
- remove QueryGenerator.continuekey
- remove BasePage.editTime()
- remove APISite.messages and APISite.validate_tokens
- drop *all* parameters in APISite.get_tokens
- remove BaseSite.use_hard_category_redirects property
- drop legacy API tokens support which are deprecated since MW 1.24
- remove TokenWallet.load_tokens()
Bug: T401802
Change-Id: I5e96a91cd2054c8603fa88afd5203a9014526a24
---
M ROADMAP.rst
M pywikibot/data/api/_generators.py
M pywikibot/page/_basepage.py
M pywikibot/site/_apisite.py
M pywikibot/site/_basesite.py
M pywikibot/site/_tokenwallet.py
M tests/page_tests.py
7 files changed, 25 insertions(+), 99 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 76a3375..830c344 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -12,6 +12,19 @@
**Code cleanups**
+* ``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`)
+* ``use_hard_category_redirect`` Site and Family properties were removed.
(:phab:`T348953`)
+* The *all* parameter of
:meth:`APISite.get_tokens()<pywikibot.site._apisite.APISite.get_tokens>``
+ was removed; use an empty string instead.
+* ``APISite.validate_tokens()`` method was removed.
+* ``APISite.messages()`` method was removed in favour of the
+ :attr:`userinfo['messages']<pywikibot.site._apisite.APISite.userinfo>`
attribute
+* ``Page.editTime()`` method was removed; :attr:`Page.latest_revision.timestamp
+ <page.BasePage.latest_revision>` attribute can be used instead
+* ``data.api.QueryGenerator.continuekey`` was be removed in favour of
+ :attr:`data.api.QueryGenerator.modules`
* The ``Timestamp.clone()`` method was removed in favour of the
``Timestamp.replace()`` method
* The ``tools.itertools.itergroup`` function was removed in favour of the
:func:`backports.batched` or
:pylib:`itertools.batched<itertools#itertools.batched>` function.
@@ -61,8 +74,6 @@
* 10.7.0: Dysfunctional :meth:`APISite.alllinks()
<pywikibot.site._generators.GeneratorsMixin.alllinks>` will be removed.
(:phab:`T359427`, :phab:`T407708`)
-* 8.4.0: :attr:`data.api.QueryGenerator.continuekey` will be removed in favour
of
- :attr:`data.api.QueryGenerator.modules`
* 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
@@ -74,11 +85,6 @@
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
-* 8.0.0: The
:meth:`APISite.messages()<pywikibot.site._apisite.APISite.messages>` method is
- deprecated in favour of the
:attr:`userinfo['messages']<pywikibot.site._apisite.APISite.userinfo>`
- attribute
-* 8.0.0: The :meth:`Page.editTime()<page.BasePage.editTime>` method is
deprecated and should be
- replaced by the
:attr:`Page.latest_revision.timestamp<page.BasePage.latest_revision>` attribute
Pending removal in Pywikibot 12
diff --git a/pywikibot/data/api/_generators.py
b/pywikibot/data/api/_generators.py
index ae6afd3..4f6297f 100644
--- a/pywikibot/data/api/_generators.py
+++ b/pywikibot/data/api/_generators.py
@@ -26,7 +26,6 @@
UnsupportedPageError,
)
from pywikibot.site import Namespace
-from pywikibot.tools import deprecated
from pywikibot.tools.collections import GeneratorWrapper
@@ -378,12 +377,6 @@
self._add_slots()
- @property
- @deprecated('modules', since='8.4.0')
- def continuekey(self) -> list[str]:
- """Return deprecated continuekey which is self.modules."""
- return self.modules
-
def _add_slots(self) -> None:
"""Add slots to params if the site supports multi-content revisions.
diff --git a/pywikibot/page/_basepage.py b/pywikibot/page/_basepage.py
index 2d0e775..db6cacd 100644
--- a/pywikibot/page/_basepage.py
+++ b/pywikibot/page/_basepage.py
@@ -780,16 +780,6 @@
return None
- @deprecated('latest_revision.timestamp', since='8.0.0')
- def editTime(self) -> pywikibot.Timestamp:
- """Return timestamp of last revision to page.
-
- .. deprecated:: 8.0
- Use :attr:`latest_revision.timestamp<latest_revision>`
- instead.
- """
- return self.latest_revision.timestamp # type: ignore[attr-defined]
-
def exists(self) -> bool:
"""Return True if page exists on the wiki, even if it's a redirect.
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index e961e0e..a6344d1 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -949,15 +949,6 @@
"""
return group.lower() in self.userinfo['groups']
- @deprecated("userinfo['messages']", since='8.0.0')
- def messages(self) -> bool:
- """Return true if the user has new messages, and false otherwise.
-
- .. deprecated:: 8.0
- Replaced by :attr:`userinfo['messages']<userinfo>`.
- """
- return self.userinfo['messages']
-
def mediawiki_messages(
self,
keys: Iterable[str],
@@ -1698,19 +1689,7 @@
page._redirtarget = target
return page._redirtarget
- @deprecated(since='8.0.0')
- def validate_tokens(self, types: list[str]) -> list[str]:
- """Validate if requested tokens are acceptable.
-
- Valid tokens may depend on mw version.
-
- .. deprecated:: 8.0
- """
- data = self._paraminfo.parameter('query+tokens', 'type')
- assert data is not None
- return [token for token in types if token in data['type']]
-
- def get_tokens(self, types: list[str], *args, **kwargs) -> dict[str, str]:
+ def get_tokens(self, types: list[str]) -> dict[str, str]:
r"""Preload one or multiple tokens.
**Usage**
@@ -1737,10 +1716,10 @@
need a specific token. Use :attr:`tokens` property instead.
.. versionchanged:: 8.0
- ``all`` parameter is deprecated. Use an empty list for
+ *all* parameter is deprecated. Use an empty list for
``types`` instead.
- .. note:: ``args`` and ``kwargs`` are not used for deprecation
- warning only.
+ .. versionchanged:: 11.0
+ *all* parameter was removed.
.. seealso:: :api:`Tokens`
:param types: the types of token (e.g., "csrf", "login", "patrol").
@@ -1748,16 +1727,7 @@
API documentation for full list of types.
:return: a dict with retrieved valid tokens.
"""
- # deprecate 'all' parameter
- if args or kwargs:
- issue_deprecation_warning("'all' parameter",
- "empty list for 'types' parameter",
- since='8.0.0')
- load_all = kwargs.get('all', args[0] if args else False)
- else:
- load_all = False
-
- if not types or load_all is not False:
+ if not types: # load all
pdata = self._paraminfo.parameter('query+tokens', 'type')
assert pdata is not None
types = pdata['type']
diff --git a/pywikibot/site/_basesite.py b/pywikibot/site/_basesite.py
index 0100cef..24bdcbe 100644
--- a/pywikibot/site/_basesite.py
+++ b/pywikibot/site/_basesite.py
@@ -95,19 +95,6 @@
self._locked_pages: set[str] = set()
@property
- @deprecated(since='8.5.0')
- def use_hard_category_redirects(self) -> bool:
- """Hard redirects are used for this site.
-
- Originally create as property for future use for a proposal to
- replace category redirect templates with hard redirects. This
- was never implemented and is not used inside the framework.
-
- .. deprecated:: 8.5
- """
- return False
-
- @property
@cached
def throttle(self):
"""Return this Site's throttle.
diff --git a/pywikibot/site/_tokenwallet.py b/pywikibot/site/_tokenwallet.py
index a691199..d2410da 100644
--- a/pywikibot/site/_tokenwallet.py
+++ b/pywikibot/site/_tokenwallet.py
@@ -7,9 +7,7 @@
from __future__ import annotations
from collections.abc import Container
-from typing import TYPE_CHECKING, Any
-
-from pywikibot.tools import deprecated, issue_deprecation_warning
+from typing import TYPE_CHECKING
if TYPE_CHECKING:
@@ -34,7 +32,11 @@
self._last_token_key: str | None = None
def __getitem__(self, key: str) -> str:
- """Get token value for the given key."""
+ """Get token value for the given key.
+
+ .. versionchanged:: 11.0
+ Support of legacy API tokens was dropped.
+ """
if self.site.user() is None and key != 'login':
self.site.login()
@@ -45,15 +47,6 @@
if not self._tokens:
self._tokens = self.site.get_tokens([])
- # Redirect old tokens which were used by outdated MediaWiki versions
- # but show a FutureWarning for this usage:
- #
https://www.mediawiki.org/wiki/MediaWiki_1.37/Deprecation_of_legacy_API_token_parameters
- if key in {'edit', 'delete', 'protect', 'move', 'block', 'unblock',
- 'email', 'import', 'options'}:
- issue_deprecation_warning(
- f'Token {key!r}', "'csrf'", since='8.0.0')
- key = 'csrf'
-
try:
token = self._tokens[key]
except KeyError:
@@ -140,15 +133,3 @@
self.clear() # clear the cache
return [self[token_type] for token_type in types]
-
- @deprecated('clear()', since='8.0.0')
- def load_tokens(self, *args: Any, **kwargs: Any) -> None:
- """Clear cache to lazy load tokens when needed.
-
- .. deprecated:: 8.0
- Use :meth:`clear` instead.
- .. versionchanged:: 8.0
- Clear the cache instead of loading tokens. All parameters are
- ignored.
- """
- self.clear()
diff --git a/tests/page_tests.py b/tests/page_tests.py
index a023de2..df1ca68 100755
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -474,11 +474,10 @@
with suppress_warnings(
r'pywikibot\.page\._basepage.BasePage\.\w+ is deprecated since '
- r'release [89]\.[03]\.0; use latest_revision\..+ instead\.',
+ r'release 9\.3\.0; use latest_revision\..+ instead\.',
FutureWarning):
self.assertIsInstance(mainpage.userName(), str)
self.assertIsInstance(mainpage.isIpEdit(), bool)
- self.assertIsInstance(mainpage.editTime(), pywikibot.Timestamp)
self.assertIsInstance(mainpage.exists(), bool)
self.assertIsInstance(mainpage.isRedirectPage(), bool)
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1201738?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: I5e96a91cd2054c8603fa88afd5203a9014526a24
Gerrit-Change-Number: 1201738
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]