jenkins-bot merged this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[docs] Add @rtype for Page.getReferences and related methods

Page.getReferences, APISite.pagebacklinks, APISite.pagereferences,
and APISite.page_embeddedin return an iterable of page objects.

Also explicitly use typing.Iterable instead of Iterable so that it won't
be confused with collections.abc.Iterable (which does not support
__getitem__ protocol).

Replace pywikibot.APISite which does not exist with
pywikibot.site.APISite.

+ Other minor changes.

Change-Id: Ic1aaa6b18300465c7158f6bc00a04bbe24696a93
---
M pywikibot/page.py
M pywikibot/site.py
M pywikibot/textlib.py
M tests/aspects.py
4 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/pywikibot/page.py b/pywikibot/page.py
index b7f2dbc..97edd3b 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -917,7 +917,7 @@
not actually exist on the wiki.

@return: Page or None if self is a special page.
- @rtype: Page or None
+ @rtype: typing.Optional[pywikibot.Page]
"""
ns = self.namespace()
if ns < 0: # Special page
@@ -1039,6 +1039,7 @@
@param total: iterate no more than this number of pages in total
@param content: if True, retrieve the content of the current version
of each referring page (default False)
+ @rtype: typing.Iterable[pywikibot.Page]
"""
# N.B.: this method intentionally overlaps with backlinks() and
# embeddedin(). Depending on the interface, it may be more efficient
@@ -3417,7 +3418,7 @@
page title (optional)
@type subpage: str
@return: Page object of user page or user subpage
- @rtype: Page
+ @rtype: pywikibot.Page
"""
if self._isAutoblock:
# This user is probably being queried for purpose of lifting
@@ -3436,7 +3437,7 @@
talk page title (optional)
@type subpage: str
@return: Page object of user talk page or user talk subpage
- @rtype: Page
+ @rtype: pywikibot.Page
"""
if self._isAutoblock:
# This user is probably being queried for purpose of lifting
diff --git a/pywikibot/site.py b/pywikibot/site.py
index d074b6c..388964c 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -1878,9 +1878,9 @@
@param dbname: database name
@type dbname: str
@param site: Site to load sitematrix from. (Default meta.wikimedia.org)
- @type site: APISite
+ @type site: pywikibot.site.APISite
@return: site object for the database name
- @rtype: APISite
+ @rtype: pywikibot.site.APISite
"""
# TODO this only works for some WMF sites
if not site:
@@ -3652,6 +3652,7 @@
@param total: Maximum number of pages to retrieve in total.
@param content: if True, load the current content of each iterated page
(default False)
+ @rtype: typing.Iterable[pywikibot.Page]
@raises KeyError: a namespace identifier was not resolved
@raises TypeError: a namespace identifier has an inappropriate
type such as NoneType or bool
@@ -3711,6 +3712,7 @@
list of namespace identifiers.
@param content: if True, load the current content of each iterated page
(default False)
+ @rtype: typing.Iterable[pywikibot.Page]
@raises KeyError: a namespace identifier was not resolved
@raises TypeError: a namespace identifier has an inappropriate
type such as NoneType or bool
@@ -3742,6 +3744,7 @@
@type namespaces: iterable of basestring or Namespace key,
or a single instance of those types. May be a '|' separated
list of namespace identifiers.
+ @rtype: typing.Iterable[pywikibot.Page]
@raises KeyError: a namespace identifier was not resolved
@raises TypeError: a namespace identifier has an inappropriate
type such as NoneType or bool
@@ -6905,7 +6908,7 @@
shows all protection levels.
@type level: str or False
@return: The pages which are protected.
- @rtype: Iterable[pywikibot.Page]
+ @rtype: typing.Iterable[pywikibot.Page]
"""
namespaces = self.namespaces.resolve(namespace)
# always assert that, so we are be sure that type could be 'create'
@@ -7028,7 +7031,7 @@
@type lint_from: str representing digit or integer

@return: pages with Linter errors.
- @rtype: Iterable[pywikibot.Page]
+ @rtype: typing.Iterable[pywikibot.Page]

"""
query = self._generator(api.ListGenerator, type_arg='linterrors',
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index b0ee716..d92bc93 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -644,7 +644,7 @@
callable
@param site: a Site object to use. It should match the origin
or target site of the text
- @type site: pywikibot.APISite
+ @type site: pywikibot.site.APISite
"""
def to_link(source):
"""Return the link from source when it's a Page otherwise itself."""
diff --git a/tests/aspects.py b/tests/aspects.py
index 09e817e..4d7e6bc 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -183,11 +183,11 @@
if additional items are in the iterator.

@param gen: Page generator
- @type gen: Iterable[pywikibot.BasePage]
+ @type gen: typing.Iterable[pywikibot.Page]
@param count: number of pages to get
@type count: int
@param site: Site of expected pages
- @type site: pywikibot.APISite
+ @type site: pywikibot.site.APISite
"""
original_iter = iter(gen)

@@ -271,11 +271,11 @@
Only iterates to the length of titles plus two.

@param gen: Page generator
- @type gen: Iterable[pywikibot.BasePage]
+ @type gen: typing.Iterable[pywikibot.Page]
@param titles: Expected titles
@type titles: iterator
@param site: Site of expected pages
- @type site: pywikibot.APISite
+ @type site: pywikibot.site.APISite
"""
titles = self._get_canonical_titles(titles, site)
gen_titles = self._get_gen_titles(gen, len(titles), site)
@@ -288,11 +288,11 @@
Only iterates to the length of titles plus two.

@param gen: Page generator
- @type gen: Iterable[pywikibot.BasePage]
+ @type gen: typing.Iterable[pywikibot.Page]
@param titles: Expected titles
@type titles: iterator
@param site: Site of expected pages
- @type site: pywikibot.APISite
+ @type site: pywikibot.site.APISite
"""
titles = self._get_canonical_titles(titles, site)
gen_titles = self._get_gen_titles(gen, len(titles), site)
@@ -1065,7 +1065,7 @@
"""Create a Page object for the sites main page.

@param site: Override current site, obtained using L{get_site}.
- @type site: pywikibot.APISite or None
+ @type site: pywikibot.site.APISite or None
@param force: Get an unused Page object
@type force: bool
@rtype: pywikibot.Page

To view, visit change 513544. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic1aaa6b18300465c7158f6bc00a04bbe24696a93
Gerrit-Change-Number: 513544
Gerrit-PatchSet: 1
Gerrit-Owner: Dalba <dalba.wiki@gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot (75)