jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/688416 )
Change subject: [bugfix] BasePage does not have a title attribute
......................................................................
[bugfix] BasePage does not have a title attribute
Use title() instead
Change-Id: Idcbac10294a0b270a593a41d49079de342dc04df
---
M pywikibot/page/__init__.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
JJMC89: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index a92c111..d3286a5 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -1827,7 +1827,7 @@
for item in self.site.deletedrevs(self, start=timestamp,
content=content, total=1, **kwargs):
# should only be one item with one revision
- if item['title'] == self.title:
+ if item['title'] == self.title():
if 'revisions' in item:
return item['revisions'][0]
return []
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/688416
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Idcbac10294a0b270a593a41d49079de342dc04df
Gerrit-Change-Number: 688416
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Huji <huji.huji(a)gmail.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/688362 )
Change subject: [W0612] Hide unused loop variables
......................................................................
[W0612] Hide unused loop variables
Also fix addtext docstring
Change-Id: Ib8bfdea44590a63016c5f92edad5e59867adbd06
---
M scripts/add_text.py
M tests/site_tests.py
M tests/ui_tests.py
3 files changed, 7 insertions(+), 9 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/add_text.py b/scripts/add_text.py
index 3588f11..f937434 100755
--- a/scripts/add_text.py
+++ b/scripts/add_text.py
@@ -171,13 +171,13 @@
@param always: Always add text without user confirmation
@param up: If True, add text to top of page, else add at bottom.
@param putText: If True, save changes to the page, else return
- (_, newtext, _)
+ (text, newtext, always)
@param oldTextGiven: If None fetch page text, else use this text
@param reorderEnabled: If True place text above categories and
interwiki, else place at page bottom. No effect if up = False.
@param create: Create page if it does not exist
@return: If putText=True: (success, success, always)
- else: (_, newtext, _)
+ else: (text, newtext, always)
"""
site = page.site
if not summary:
@@ -343,11 +343,9 @@
if talkPage:
generator = pagegenerators.PageWithTalkPageGenerator(generator, True)
for page in generator:
- (_, newtext, _) = add_text(page, addText, summary,
- regexSkipUrl=regexSkipUrl,
- always=always, up=up,
- reorderEnabled=reorderEnabled,
- create=talkPage)
+ add_text(page, addText, summary,
+ regexSkipUrl=regexSkipUrl, always=always, up=up,
+ reorderEnabled=reorderEnabled, create=talkPage)
if __name__ == '__main__':
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 36cc1f4..4ffff26 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -953,7 +953,7 @@
"""Test lock_page and unlock_page methods for multiple threads."""
# Start few threads
threads = []
- for i in range(5):
+ for _ in range(5):
thread = threading.Thread(target=self.worker)
thread.setDaemon(True)
thread.start()
diff --git a/tests/ui_tests.py b/tests/ui_tests.py
index 1cf3cad..0bfe4d8 100644
--- a/tests/ui_tests.py
+++ b/tests/ui_tests.py
@@ -638,7 +638,7 @@
'Alpha Bετα Гамма دلتا\n')
lines = []
- for i in range(3):
+ for _ in range(3):
lines = self.getstdouterr().split('\n')
if len(lines) >= 4 and 'Alpha' not in lines:
# if len(lines) < 4, we assume not all lines had been output
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/688362
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ib8bfdea44590a63016c5f92edad5e59867adbd06
Gerrit-Change-Number: 688362
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/688324 )
Change subject: [IMPR] use consecutive reference numbers for autogenerated links
......................................................................
[IMPR] use consecutive reference numbers for autogenerated links
currently free_number gives a randomized next free number for
autogenerated links because set is not ordered. Use a generator
instead.
Change-Id: I1d4489de77496579d77ff0cecf8550779454378b
---
M scripts/reflinks.py
1 file changed, 3 insertions(+), 3 deletions(-)
Approvals:
Rubin: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/reflinks.py b/scripts/reflinks.py
index 2104cca..bb889be 100755
--- a/scripts/reflinks.py
+++ b/scripts/reflinks.py
@@ -350,9 +350,9 @@
with suppress(ValueError):
used_numbers.add(int(number))
- # iterator to give the next free number
- free_number = iter({str(i) for i in range(1, 1000) # should be enough
- if i not in used_numbers})
+ # generator to give the next free number
+ free_number = (str(i) for i in range(1, 1000) # should be enough
+ if i not in used_numbers)
for (g, d) in found_refs.items():
group = ''
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/688324
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I1d4489de77496579d77ff0cecf8550779454378b
Gerrit-Change-Number: 688324
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: MarcoAurelio <maurelio(a)tools.wmflabs.org>
Gerrit-Reviewer: Rubin <rubin.happy(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/688337 )
Change subject: [bugfix] Fix too many positional arguments for constructor call
......................................................................
[bugfix] Fix too many positional arguments for constructor call
image.ImageRobot has only 3 positional arguments.
Add keyword arguments to instantiate the bot
See https://deepsource.io/gh/xqt/pywikibot/issue/PYL-E1121/occurrences
Change-Id: Icea3a9516f42e36a10e3a7eda1fcf8ea69821a0f
---
M scripts/nowcommons.py
1 file changed, 9 insertions(+), 10 deletions(-)
Approvals:
Rubin: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/nowcommons.py b/scripts/nowcommons.py
index bebea54..9620ff5 100755
--- a/scripts/nowcommons.py
+++ b/scripts/nowcommons.py
@@ -283,7 +283,7 @@
'is still used in {1} pages.',
local_file_page.title(with_ns=False),
len(using_pages)))
- if self.opt.replace is True:
+ if self.opt.replace:
pywikibot.output(color_format(
'Replacing "{lightred}{0}{default}" by '
'"{lightgreen}{1}{default}\".',
@@ -293,8 +293,8 @@
pg.FileLinksGenerator(local_file_page),
local_file_page.title(with_ns=False),
commons_file_page.title(with_ns=False),
- '', self.opt.replacealways,
- self.opt.replaceloose)
+ always=self.opt.replacealways,
+ loose=self.opt.replaceloose)
bot.run()
# If the image is used with the urlname the
# previous function won't work
@@ -303,13 +303,12 @@
page.title()).using_pages(total=1)))
if is_used and self.opt.replaceloose:
bot = ImageBot(
- pg.FileLinksGenerator(
- local_file_page),
- local_file_page.title(
- with_ns=False, as_url=True),
+ pg.FileLinksGenerator(local_file_page),
+ local_file_page.title(with_ns=False,
+ as_url=True),
commons_file_page.title(with_ns=False),
- '', self.opt.replacealways,
- self.opt.replaceloose)
+ always=self.opt.replacealways,
+ loose=self.opt.replaceloose)
bot.run()
# refresh because we want the updated list
using_pages = len(list(pywikibot.FilePage(
@@ -323,7 +322,7 @@
'anymore.',
local_file_page.title(with_ns=False)))
commons_text = commons_file_page.get()
- if self.opt.replaceonly is False:
+ if not self.opt.replaceonly:
if sha1 == commons_file_page.latest_file_info.sha1:
pywikibot.output(
'The file is identical to the one on Commons.')
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/688337
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Icea3a9516f42e36a10e3a7eda1fcf8ea69821a0f
Gerrit-Change-Number: 688337
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Rubin <rubin.happy(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/688347 )
Change subject: [W0120] Useless else clause detected on the loop
......................................................................
[W0120] Useless else clause detected on the loop
When a loop specifies no break statement, the else clause will always
execute when the loop sequence is empty, thus making it useless. It is
recommended to have the statements under else in the same scope as the
loop itself. If the else clause does not always execute at the end of a
loop clause, then the code should add a break statement within the loop
block.
Change-Id: I57a8b70da399a869554c8ab78e6eefad18ac1f6d
---
M docs/conf.py
M pywikibot/bot.py
M pywikibot/bot_choice.py
M pywikibot/comms/eventstreams.py
M pywikibot/data/api.py
M pywikibot/site/_apisite.py
M scripts/interwiki.py
M tests/textlib_tests.py
8 files changed, 28 insertions(+), 30 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/conf.py b/docs/conf.py
index 4be6958..d3e68ae 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -493,8 +493,8 @@
return safe_getattr(obj, name, *defargs)
return prop
- else:
- return safe_getattr(obj, name, *defargs)
+
+ return safe_getattr(obj, name, *defargs)
def setup(app):
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 08fbdc3..0d90522 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -645,8 +645,8 @@
for c in self.choices:
if c.shortcut == choice:
return c.handle()
- else:
- raise ValueError('Invalid choice "{}"'.format(choice))
+
+ raise ValueError('Invalid choice "{}"'.format(choice))
def __call__(self, link, text, groups, rng):
"""Ask user how the selected link should be replaced."""
@@ -1532,8 +1532,8 @@
# Process the page
self.treat(page)
self._treat_counter += 1
- else:
- self._generator_completed = True
+
+ self._generator_completed = True
except QuitKeyboardInterrupt:
pywikibot.output('\nUser quit {} bot run...'
.format(self.__class__.__name__))
diff --git a/pywikibot/bot_choice.py b/pywikibot/bot_choice.py
index 433acc1..4f2abe9 100755
--- a/pywikibot/bot_choice.py
+++ b/pywikibot/bot_choice.py
@@ -178,8 +178,8 @@
handled = option.handled(value)
if handled is not None:
return handled
- else:
- return super().handled(value)
+
+ return super().handled(value)
def output(self):
"""Output the suboptions."""
diff --git a/pywikibot/comms/eventstreams.py b/pywikibot/comms/eventstreams.py
index 053ce0e..eba15ef 100644
--- a/pywikibot/comms/eventstreams.py
+++ b/pywikibot/comms/eventstreams.py
@@ -10,7 +10,7 @@
*New in version 3.0.*
"""
#
-# (C) Pywikibot team, 2017-2020
+# (C) Pywikibot team, 2017-2021
#
# Distributed under the terms of the MIT license.
#
@@ -323,9 +323,9 @@
warning('Encountered error: {}'.format(event.data))
else:
warning('Unknown event {} occurred.'.format(event.event))
- else:
- debug('{}: Stopped iterating due to exceeding item limit.'
- .format(self.__class__.__name__), _logger)
+
+ debug('{}: Stopped iterating due to exceeding item limit.'
+ .format(self.__class__.__name__), _logger)
del self.source
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 576bcec..b822ede 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1348,8 +1348,8 @@
action = err_msg.get(message)
if action is True or action == self.action:
return True
- else:
- return False
+
+ return False
if isinstance(messages, dict):
try: # behaviour before gerrit 124323 breaking change
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index b10743b..d0cabef 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -651,8 +651,8 @@
except KeyError:
raise KeyError("No message '{}' found for lang '{}'"
.format(key, amlang))
- else:
- return result
+
+ return result
return OrderedDict((key, _mw_msg_cache[amlang][key]) for key in keys)
@@ -1260,17 +1260,15 @@
for _from, _to in redirmap.items():
if _to['title'] in redirmap:
raise CircularRedirectError(page)
- else:
- target = pywikibot.Page(source=page.site, title=target_title)
- # Check if target is on another site.
- if target.site != page.site:
- raise InterwikiRedirectPageError(page, target)
-
- # Redirect to Special: & Media: pages, which do not work
- # like redirects, but are rendered like a redirect.
- page._redirtarget = target
- return page._redirtarget
+ target = pywikibot.Page(source=page.site, title=target_title)
+ # Check if target is on another site.
+ if target.site != page.site:
+ raise InterwikiRedirectPageError(page, target)
+ # Redirect to Special: & Media: pages, which do not work
+ # like redirects, but are rendered like a redirect.
+ page._redirtarget = target
+ return page._redirtarget
pagedata = list(result['query']['pages'].values())[0]
# There should be only one value in 'pages' (the ultimate
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index 103fcc0..7af2748 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -2303,8 +2303,8 @@
self._next_page = page.title(with_ns=False) + '!'
self._next_namespace = page.namespace()
yield page
- else:
- self.restored_files.add(filename)
+
+ self.restored_files.add(filename)
if self.opt.do_continue:
yield from self.site.allpages(start=self.next_page,
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py
index 95a1b83..fe3ece0 100644
--- a/tests/textlib_tests.py
+++ b/tests/textlib_tests.py
@@ -222,8 +222,8 @@
new = textlib.replaceCategoryInPlace(temp, dummy, cat,
site=self.site)
self.assertEqual(self.old, new)
- else:
- self.assertEqual(count, 3)
+
+ self.assertEqual(count, 3)
# Testing removing categories
temp = textlib.replaceCategoryInPlace(self.old, cats[0],
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/688347
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I57a8b70da399a869554c8ab78e6eefad18ac1f6d
Gerrit-Change-Number: 688347
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/688326 )
Change subject: [len] remove unnecessary len() for boolean result
......................................................................
[len] remove unnecessary len() for boolean result
Change-Id: I492b0ff3c13182ca8174867a99985e2ef5cc50bb
---
M tests/aspects.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/aspects.py b/tests/aspects.py
index 4ad3c4b..f9da3cc 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -700,7 +700,7 @@
if 'family' in dct or 'code' in dct:
dct['site'] = True
- if (('sites' not in dct or not len(dct['sites']))
+ if (('sites' not in dct or not dct['sites'])
and 'family' in dct
and 'code' in dct and dct['code'] != '*'):
# Add entry to self.sites
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/688326
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I492b0ff3c13182ca8174867a99985e2ef5cc50bb
Gerrit-Change-Number: 688326
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged