jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/630334 )
Change subject: [cleanup] Cleanup deprecated recentchanges parameter ......................................................................
[cleanup] Cleanup deprecated recentchanges parameter
- remove rcprop which was never used neither in compat nor in core - show a FutureWarning for returndict, nobots, rcshow, revision, repeat, rcdir, step and pagelist - add type hints to current parameters of Site.recentchanges - deprecate unused pagelist parameter in RecentChangesPageGenerator - add type hints to current parameters of RecentChangesPageGenerator - use keyword arguments only for RecentChangesPageGenerator function and Site.recentchanges method
Change-Id: Id0de5c6abbd194049428c6c864f26ff5e8edd086 --- M pywikibot/pagegenerators.py M pywikibot/site/__init__.py 2 files changed, 48 insertions(+), 51 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py index b9b163e..5dd091d 100644 --- a/pywikibot/pagegenerators.py +++ b/pywikibot/pagegenerators.py @@ -31,6 +31,7 @@ from functools import partial from itertools import zip_longest from requests.exceptions import ReadTimeout +from typing import List, Optional, Union from warnings import warn
import pywikibot @@ -1348,15 +1349,25 @@ total=total, returndict=True))
-@deprecated_args(nobots=None, step=None) -def RecentChangesPageGenerator(start=None, end=None, reverse=False, - namespaces=None, pagelist=None, - changetype=None, showMinor=None, - showBot=None, showAnon=None, - showRedirects=None, showPatrolled=None, - topOnly=False, total=None, - user=None, excludeuser=None, site=None, - tag=None, _filter_unique=None): +@deprecated_args(nobots=True, pagelist=True, step=True) +def RecentChangesPageGenerator(*, + start=None, + end=None, + reverse: bool = False, + namespaces=None, + changetype: Optional[str] = None, + showMinor: Optional[bool] = None, + showBot: Optional[bool] = None, + showAnon: Optional[bool] = None, + showRedirects: Optional[bool] = None, + showPatrolled: Optional[bool] = None, + topOnly: bool = False, + total: Optional[int] = None, + user: Union[str, List[str], None] = None, + excludeuser: Union[str, List[str], None] = None, + site=None, + tag: Optional[str] = None, + _filter_unique=None): """ Generate pages that are in the recent changes list, including duplicates.
@@ -1365,55 +1376,40 @@ @param end: Timestamp to end listing at @type end: pywikibot.Timestamp @param reverse: if True, start with oldest changes (default: newest) - @type reverse: bool - @param pagelist: iterate changes to pages in this list only - @param pagelist: list of Pages @param changetype: only iterate changes of this type ("edit" for edits to existing pages, "new" for new pages, "log" for log entries) - @type changetype: basestring @param showMinor: if True, only list minor edits; if False, only list non-minor edits; if None, list all - @type showMinor: bool or None @param showBot: if True, only list bot edits; if False, only list non-bot edits; if None, list all - @type showBot: bool or None @param showAnon: if True, only list anon edits; if False, only list non-anon edits; if None, list all - @type showAnon: bool or None @param showRedirects: if True, only list edits to redirect pages; if False, only list edits to non-redirect pages; if None, list all - @type showRedirects: bool or None @param showPatrolled: if True, only list patrolled edits; if False, only list non-patrolled edits; if None, list all - @type showPatrolled: bool or None @param topOnly: if True, only list changes that are the latest revision (default False) - @type topOnly: bool @param user: if not None, only list edits by this user or users - @type user: basestring|list @param excludeuser: if not None, exclude edits by this user or users - @type excludeuser: basestring|list @param site: Site for generator results. @type site: L{pywikibot.site.BaseSite} @param tag: a recent changes tag - @type tag: str """ if site is None: site = pywikibot.Site()
gen = site.recentchanges(start=start, end=end, reverse=reverse, - namespaces=namespaces, pagelist=pagelist, - changetype=changetype, minor=showMinor, - bot=showBot, anon=showAnon, - redirect=showRedirects, - patrolled=showPatrolled, - top_only=topOnly, total=total, - user=user, excludeuser=excludeuser, tag=tag) + namespaces=namespaces, changetype=changetype, + minor=showMinor, bot=showBot, anon=showAnon, + redirect=showRedirects, patrolled=showPatrolled, + top_only=topOnly, total=total, user=user, + excludeuser=excludeuser, tag=tag)
gen.request['rcprop'] = 'title' - gen = (pywikibot.Page(site, x['title']) - for x in gen if x['type'] != 'log' or 'title' in x) + gen = (pywikibot.Page(site, rc['title']) + for rc in gen if rc['type'] != 'log' or 'title' in rc)
if _filter_unique: gen = _filter_unique(gen) diff --git a/pywikibot/site/__init__.py b/pywikibot/site/__init__.py index ef6becb..e2c424d 100644 --- a/pywikibot/site/__init__.py +++ b/pywikibot/site/__init__.py @@ -29,7 +29,7 @@ from enum import IntEnum from itertools import zip_longest from textwrap import fill -from typing import Optional +from typing import List, Optional, Union from warnings import warn
import pywikibot @@ -4049,18 +4049,30 @@
return legen
- @deprecated_args(returndict=None, nobots=None, rcshow=None, rcprop=None, - rctype='changetype', revision=None, repeat=None, - rcstart='start', rcend='end', rcdir=None, step=None, + @deprecated_args(returndict=True, nobots=True, rcshow=True, + rctype='changetype', revision=True, repeat=True, + rcstart='start', rcend='end', rcdir=True, step=True, includeredirects='redirect', namespace='namespaces', rcnamespace='namespaces', number='total', rclimit='total', showMinor='minor', showBot='bot', showAnon='anon', showRedirects='redirect', showPatrolled='patrolled', - topOnly='top_only', pagelist=None) - def recentchanges(self, start=None, end=None, reverse=False, - namespaces=None, changetype=None, minor=None, bot=None, - anon=None, redirect=None, patrolled=None, top_only=False, - total=None, user=None, excludeuser=None, tag=None): + topOnly='top_only', pagelist=True) + def recentchanges(self, *, + start=None, + end=None, + reverse: bool = False, + namespaces=None, + changetype: Optional[str] = None, + minor: Optional[bool] = None, + bot: Optional[bool] = None, + anon: Optional[bool] = None, + redirect: Optional[bool] = None, + patrolled: Optional[bool] = None, + top_only: bool = False, + total: Optional[int] = None, + user: Union[str, List[str], None] = None, + excludeuser: Union[str, List[str], None] = None, + tag: Optional[str] = None): """Iterate recent changes.
@see: U{https://www.mediawiki.org/wiki/API:RecentChanges%7D @@ -4070,7 +4082,6 @@ @param end: Timestamp to end listing at @type end: pywikibot.Timestamp @param reverse: if True, start with oldest changes (default: newest) - @type reverse: bool @param namespaces: only iterate pages in these namespaces @type namespaces: iterable of basestring or Namespace key, or a single instance of those types. May be a '|' separated @@ -4078,31 +4089,21 @@ @param changetype: only iterate changes of this type ("edit" for edits to existing pages, "new" for new pages, "log" for log entries) - @type changetype: basestring @param minor: if True, only list minor edits; if False, only list non-minor edits; if None, list all - @type minor: bool or None @param bot: if True, only list bot edits; if False, only list non-bot edits; if None, list all - @type bot: bool or None @param anon: if True, only list anon edits; if False, only list non-anon edits; if None, list all - @type anon: bool or None @param redirect: if True, only list edits to redirect pages; if False, only list edits to non-redirect pages; if None, list all - @type redirect: bool or None @param patrolled: if True, only list patrolled edits; if False, only list non-patrolled edits; if None, list all - @type patrolled: bool or None @param top_only: if True, only list changes that are the latest revision (default False) - @type top_only: bool @param user: if not None, only list edits by this user or users - @type user: basestring|list @param excludeuser: if not None, exclude edits by this user or users - @type excludeuser: basestring|list @param tag: a recent changes tag - @type tag: str @raises KeyError: a namespace identifier was not resolved @raises TypeError: a namespace identifier has an inappropriate type such as NoneType or bool
pywikibot-commits@lists.wikimedia.org