jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/474126 )
Change subject: [PEP8] Fix W504 issues in four python scripts ......................................................................
[PEP8] Fix W504 issues in four python scripts
This patch fixes code style issues in four python scripts. The problem was that there was a line break after a binary operator. The patch took place in config2.py, diff.py, i18n.py and proofreadpage.py.
Bug: T207836 Change-Id: If2454a8aa89485ea1b3a380d1f2824f5cee27519 --- M pywikibot/config2.py M pywikibot/diff.py M pywikibot/i18n.py M pywikibot/proofreadpage.py 4 files changed, 24 insertions(+), 27 deletions(-)
Approvals: Framawiki: Looks good to me, but someone else must approve D3r1ck01: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py index 2eafdf9..695ef98 100644 --- a/pywikibot/config2.py +++ b/pywikibot/config2.py @@ -332,13 +332,13 @@ base_dir = os.path.expanduser(base_dir) break else: - if ('PYWIKIBOT_DIR' in environ and - exists(os.path.abspath(environ['PYWIKIBOT_DIR']))): + if ('PYWIKIBOT_DIR' in environ + and exists(os.path.abspath(environ['PYWIKIBOT_DIR']))): base_dir = os.path.abspath(environ['PYWIKIBOT_DIR']) elif exists('.'): base_dir = os.path.abspath('.') - elif ('PYWIKIBOT_DIR_PWB' in environ and - exists(os.path.abspath(environ['PYWIKIBOT_DIR_PWB']))): + elif ('PYWIKIBOT_DIR_PWB' in environ + and exists(os.path.abspath(environ['PYWIKIBOT_DIR_PWB']))): base_dir = os.path.abspath(environ['PYWIKIBOT_DIR_PWB']) else: base_dir_cand = [] @@ -1072,8 +1072,8 @@
def _assert_default_type(name, value, default_value): """Return the value if the old or new is None or both same type.""" - if (value is None or default_value is None or - isinstance(value, type(default_value))): + if (value is None or default_value is None + or isinstance(value, type(default_value))): return value elif isinstance(value, int) and isinstance(default_value, float): return float(value) @@ -1115,8 +1115,8 @@
# Copy the user config settings into globals _modified = [_key for _key in _gl - if _uc[_key] != globals()[_key] or - _key in ('usernames', 'sysopnames', 'disambiguation_comment')] + if _uc[_key] != globals()[_key] + or _key in ('usernames', 'sysopnames', 'disambiguation_comment')]
if ('user_agent_format' in _modified): _right_user_agent_format = re.sub(r'{httplib2(:|})', r'{http_backend\1', @@ -1176,13 +1176,13 @@ # Fix up socket_timeout # Older requests library expect a single value whereas newer versions also # accept a tuple (connect timeout, read timeout). -if (isinstance(socket_timeout, tuple) and - StrictVersion(requests_version) < StrictVersion('2.4.0')): +if (isinstance(socket_timeout, tuple) + and StrictVersion(requests_version) < StrictVersion('2.4.0')): socket_timeout = max(socket_timeout)
# SECURITY WARNINGS -if (not ignore_file_security_warnings and - private_files_permission & (stat.S_IRWXG | stat.S_IRWXO) != 0): +if (not ignore_file_security_warnings + and private_files_permission & (stat.S_IRWXG | stat.S_IRWXO) != 0): error("CRITICAL SECURITY WARNING: 'private_files_permission' is set" ' to allow access from the group/others which' ' could give them access to the sensitive files.' diff --git a/pywikibot/diff.py b/pywikibot/diff.py index 3ce3ac7..7a49369 100644 --- a/pywikibot/diff.py +++ b/pywikibot/diff.py @@ -356,8 +356,7 @@ # anything below 4 they share lines. # not super_hunk == first hunk as any other super_hunk is # created with one hunk - if (not super_hunk or - hunk.pre_context <= self.context * 2): + if (not super_hunk or hunk.pre_context <= self.context * 2): # previous hunk has shared/adjacent self.context lines super_hunk += [hunk] else: @@ -500,9 +499,9 @@ affix=''), mode, first)] rng_width = max(len(hunk_list[-1][2]), rng_width) - line_template = ('{0}{1} {2: >' + - str(int(math.log10(len(super_hunks)) + 1)) + - '}: {3: <' + str(rng_width) + '} {4}{5}') + line_template = ('{0}{1} {2: >' + + str(int(math.log10(len(super_hunks)) + 1)) + + '}: {3: <' + str(rng_width) + '} {4}{5}') # the last entry is the first changed line which usually ends # with a \n (only the last may not, which is covered by the # if-condition following this block) @@ -519,8 +518,8 @@ next_hunk_position = int(next_hunk) - 1 except ValueError: next_hunk_position = False - if (next_hunk_position is not False and - 0 <= next_hunk_position < len(super_hunks)): + if (next_hunk_position is not False + and 0 <= next_hunk_position < len(super_hunks)): position = next_hunk_position elif next_hunk: # nothing entered is silently ignored pywikibot.error( @@ -534,9 +533,9 @@ elif choice == 'K': position -= 1 elif choice == 's': - super_hunks = (super_hunks[:position] + - super_hunks[position].split() + - super_hunks[position + 1:]) + super_hunks = (super_hunks[:position] + + super_hunks[position].split() + + super_hunks[position + 1:]) pywikibot.output( 'Split into {0} hunks'.format(len(super_hunk._hunks))) elif choice == '?': diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py index 1a62198..d6ca56e 100644 --- a/pywikibot/i18n.py +++ b/pywikibot/i18n.py @@ -835,8 +835,7 @@ # exclude languages does not have this specific message in that package # i.e. an incomplete set of translated messages. return [lang for lang in langs - if lang != 'qqq' and - _get_translation(lang, twtitle)] + if lang != 'qqq' and _get_translation(lang, twtitle)]
def input(twtitle, parameters=None, password=False, fallback_prompt=None): diff --git a/pywikibot/proofreadpage.py b/pywikibot/proofreadpage.py index 24b6a9a..e8694c1 100644 --- a/pywikibot/proofreadpage.py +++ b/pywikibot/proofreadpage.py @@ -861,9 +861,8 @@ if end is None: end = self.num_pages
- if not ((1 <= start <= self.num_pages) and - (1 <= end <= self.num_pages) and - (start <= end)): + if not ((1 <= start <= self.num_pages) + and (1 <= end <= self.num_pages) and (start <= end)): raise ValueError('start=%s, end=%s are not in valid range (%s, %s)' % (start, end, 1, self.num_pages))
pywikibot-commits@lists.wikimedia.org