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: