jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/477064 )
Change subject: [PEP8] Fix for W504 errors in pywikibot
......................................................................
[PEP8] Fix for W504 errors in pywikibot
Fixed the W504 error occurrences in the following file:
- pywikibot/bot_choice.py
- pywikibot/bot.py
- pywikibot/specialbots.py
Bug: T207836
Change-Id: I95d29fe699a6159f04d88fa36e27af2d437c49e8
---
M pywikibot/bot.py
M pywikibot/bot_choice.py
M pywikibot/specialbots.py
3 files changed, 25 insertions(+), 25 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 5cb9b06..44392d6 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -816,10 +816,10 @@
text = self.current_text
# at the beginning of the link, start red color.
# at the end of the link, reset the color to default
- pywikibot.output(text[max(0, rng[0] - self.context): rng[0]] +
- color_format('{lightred}{0}{default}',
- text[rng[0]: rng[1]]) +
- text[rng[1]: rng[1] + self.context])
+ pywikibot.output(text[max(0, rng[0] - self.context): rng[0]]
+ + color_format('{lightred}{0}{default}',
+ text[rng[0]: rng[1]])
+ + text[rng[1]: rng[1] + self.context])
question = 'Should the link '
else:
question = 'Should the link {lightred}{0}{default} '
@@ -1601,8 +1601,8 @@
# When in auto update mode, set the site when it changes,
# so subclasses can hook onto changes to site.
page = super(Bot, self).init_page(item)
- if (self._auto_update_site and
- (not self._site or page.site != self.site)):
+ if (self._auto_update_site
+ and (not self._site or page.site != self.site)):
self.site = page.site
return page
@@ -2098,10 +2098,10 @@
% (claim.getID(),))
log("Append 's' to -exists argument to override this behavior")
return False
- if ('s' not in exists_arg and source and
- any(source.getID() in ref and
- all(snak.target_equals(source.getTarget())
- for snak in ref[source.getID()])
+ if ('s' not in exists_arg and source
+ and any(source.getID() in ref
+ and all(snak.target_equals(source.getTarget())
+ for snak in ref[source.getID()])
for ref in existing.sources)):
logger_callback(
'Skipping %s because claim with the same source already '
@@ -2169,8 +2169,8 @@
# FIXME: Hack because 'is_data_repository' doesn't work if
# site is the APISite. See T85483
data_site = page.site.data_repository()
- if (data_site.family == page.site.family and
- data_site.code == page.site.code):
+ if (data_site.family == page.site.family
+ and data_site.code == page.site.code):
is_item = page.namespace() == data_site.item_namespace.id
else:
is_item = False
diff --git a/pywikibot/bot_choice.py b/pywikibot/bot_choice.py
index 4d9a882..727f144 100755
--- a/pywikibot/bot_choice.py
+++ b/pywikibot/bot_choice.py
@@ -127,8 +127,8 @@
def test(self, value):
"""Return True whether this option applies."""
- return (self.shortcut.lower() == value.lower() or
- self.option.lower() == value.lower())
+ return (self.shortcut.lower() == value.lower()
+ or self.option.lower() == value.lower())
class OutputProxyOption(OutputOption, StandardOption):
@@ -217,8 +217,8 @@
def __init__(self, minimum=1, maximum=None, prefix=''):
"""Initializer."""
super(IntegerOption, self).__init__()
- if not ((minimum is None or isinstance(minimum, int)) and
- (maximum is None or isinstance(maximum, int))):
+ if not ((minimum is None or isinstance(minimum, int))
+ and (maximum is None or isinstance(maximum, int))):
raise ValueError(
'The minimum and maximum parameters must be int or None.')
if minimum is not None and maximum is not None and minimum > maximum:
@@ -234,8 +234,8 @@
except ValueError:
return False
else:
- return ((self.minimum is None or value >= self.minimum) and
- (self.maximum is None or value <= self.maximum))
+ return ((self.minimum is None or value >= self.minimum)
+ and (self.maximum is None or value <= self.maximum))
@property
def minimum(self):
@@ -323,9 +323,9 @@
def output_range(self, start, end):
"""Show normal context with a red center region."""
- pywikibot.output(self.text[start:self.start] + '\03{lightred}' +
- self.text[self.start:self.end] + '\03{default}' +
- self.text[self.end:end])
+ pywikibot.output(self.text[start:self.start] + '\03{lightred}'
+ + self.text[self.start:self.end] + '\03{default}'
+ + self.text[self.end:end])
class ChoiceException(StandardOption, Exception):
diff --git a/pywikibot/specialbots.py b/pywikibot/specialbots.py
index 5fdfffe..2b02bad 100644
--- a/pywikibot/specialbots.py
+++ b/pywikibot/specialbots.py
@@ -209,8 +209,8 @@
if self.aborts is not True:
if warning in self.aborts:
return False
- if self.ignoreWarning is True or (self.ignoreWarning is not False and
- warning in self.ignoreWarning):
+ if self.ignoreWarning is True or (self.ignoreWarning is not False
+ and warning in self.ignoreWarning):
return True
return None if self.aborts is not True else False
@@ -418,8 +418,8 @@
success = False
ignore_warnings = self.ignoreWarning is True or self._handle_warnings
- if ('://' in file_url and
- 'upload_by_url' not in site.userinfo['rights']):
+ if ('://' in file_url
+ and 'upload_by_url' not in site.userinfo['rights']):
file_url = self.read_file_content(file_url)
try:
--
To view, visit https://gerrit.wikimedia.org/r/477064
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I95d29fe699a6159f04d88fa36e27af2d437c49e8
Gerrit-Change-Number: 477064
Gerrit-PatchSet: 7
Gerrit-Owner: YVB <yajnvb(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/479517 )
Change subject: [cleanup] pywikibot/site.py: simplify test
......................................................................
[cleanup] pywikibot/site.py: simplify test
The form using a tuple, isinstance(x, (A, B, ...)), is a shortcut for
isinstance(x, A) or isinstance(x, B) or ... (etc.).
Change-Id: I8ffa9da4f37b8851801e404e0c47ca6774dff828
---
M pywikibot/site.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 0de4971..ea0b4a3 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -5814,9 +5814,9 @@
if all(_ is None for _ in [rcid, revid, revision]):
raise Error('No rcid, revid or revision provided.')
- if isinstance(rcid, int) or isinstance(rcid, basestring):
+ if isinstance(rcid, (int, basestring)):
rcid = {rcid}
- if isinstance(revid, int) or isinstance(revid, basestring):
+ if isinstance(revid, (int, basestring)):
revid = {revid}
if isinstance(revision, pywikibot.page.Revision):
revision = {revision}
--
To view, visit https://gerrit.wikimedia.org/r/479517
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I8ffa9da4f37b8851801e404e0c47ca6774dff828
Gerrit-Change-Number: 479517
Gerrit-PatchSet: 1
Gerrit-Owner: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/477417 )
Change subject: [PEP8] Fix W504 issues across python scripts (XVII)
......................................................................
[PEP8] Fix W504 issues across python scripts (XVII)
Fixed breaking of line after a binary operator. The changes moved line
breaks in tests/textlib_tests.py and pywikibot/data/api.py. This is a
submission for GCI.
Bug: T207836
Change-Id: If3c16841cfffb020c3f50aea0554e0a76d3732de
---
M pywikibot/data/api.py
M tests/textlib_tests.py
2 files changed, 5 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index ed09a26..f7e4745 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -802,9 +802,9 @@
if 'path' not in mod_data:
# query modules often contain 'ApiQuery' and have a suffix.
# 'ApiQuery' alone is the action 'query'
- if 'querytype' in mod_data or (
- php_class and len(php_class) > 8 and
- 'ApiQuery' in php_class):
+ if ('querytype' in mod_data
+ or php_class and len(php_class) > 8
+ and 'ApiQuery' in php_class):
mod_data['path'] = 'query+' + name
else:
mod_data['path'] = name
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py
index ad659df..33a49cb 100644
--- a/tests/textlib_tests.py
+++ b/tests/textlib_tests.py
@@ -1428,8 +1428,8 @@
def test_replace_tags_interwiki(self):
"""Test replacing not inside interwiki links."""
- if ('es' not in self.site.family.langs or
- 'ey' in self.site.family.langs):
+ if ('es' not in self.site.family.langs
+ or 'ey' in self.site.family.langs):
raise unittest.SkipTest("family {} doesn't have languages"
.format(self.site))
--
To view, visit https://gerrit.wikimedia.org/r/477417
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: If3c16841cfffb020c3f50aea0554e0a76d3732de
Gerrit-Change-Number: 477417
Gerrit-PatchSet: 14
Gerrit-Owner: Stella <joannage87(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Urbanecm <martin.urbanec(a)wikimedia.cz>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)