jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/487476 )
Change subject: [tests] Don't ignore line break after binary operator ......................................................................
[tests] Don't ignore line break after binary operator
line break before binary operator is the current PEP 8 recommendation but line break after binary operator is not.
Bug: T207836 Change-Id: I28973b22f0d45c0761520c4b5595d03ed21ebe43 --- M pywikibot/data/api.py M pywikibot/data/wikistats.py M scripts/casechecker.py M scripts/flickrripper.py M scripts/wikisourcetext.py M tests/isbn_tests.py M tox.ini 7 files changed, 45 insertions(+), 44 deletions(-)
Approvals: Dalba: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index 3eea1c7..de32f17 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -396,8 +396,8 @@ 'parameters': [ { 'name': 'querymodules', - 'type': (prop_modules + list_modules + - meta_modules + gen_modules), + 'type': (prop_modules + list_modules + + meta_modules + gen_modules), 'limit': 50, }, ], @@ -522,8 +522,8 @@ # Purge is the only action which isn't POSTed but actually does # require writerights. This was checked with the data from # 1.25wmf22 on en.wikipedia.org. - if ('mustbeposted' in self._paraminfo[path] and - path != 'login') or path == 'purge': + if ('mustbeposted' in self._paraminfo[path] + and path != 'login') or path == 'purge': self._paraminfo[path]['writerights'] = ''
self._emulate_pageset() @@ -694,8 +694,8 @@ # This is supplying submodules even if they aren't submodules # of the given module so skip those for param in parameters: - if ((module == 'main' and param['name'] == 'format') or - 'submodules' not in param): + if ((module == 'main' and param['name'] == 'format') + or 'submodules' not in param): continue for submodule in param['submodules'].values(): if '+' in submodule: @@ -720,8 +720,9 @@
for param in parameters: # Do not add format modules - if 'submodules' in param and (module != 'main' or - param['name'] != 'format'): + if ('submodules' in param + and (module != 'main' + or param['name'] != 'format')): submodules |= set(param['type'])
if submodules: @@ -1114,8 +1115,8 @@ self._enabled &= self._valid_enable self._disabled &= self._valid_disable else: - invalid_names = ((self._enabled - self._valid_enable) | - (self._disabled - self._valid_disable)) + invalid_names = ((self._enabled - self._valid_enable) + | (self._disabled - self._valid_disable)) if invalid_names: raise KeyError('OptionSet already contains invalid name(s) ' '"{0}"'.format('", "'.join(invalid_names))) @@ -1149,8 +1150,8 @@ raise ValueError('Dict contains invalid value "{0}"'.format( value)) invalid_names = ( - (enabled - self._valid_enable) | (disabled - self._valid_disable) | - (removed - self._valid_enable - self._valid_disable) + (enabled - self._valid_enable) | (disabled - self._valid_disable) + | (removed - self._valid_enable - self._valid_disable) ) if invalid_names and self._site_set: raise ValueError('Dict contains invalid name(s) "{0}"'.format( @@ -1176,8 +1177,8 @@ self._disabled.add(name) self._enabled.discard(name) elif value is None: - if self._site_set and (name not in self._valid_enable or - name not in self._valid_disable): + if self._site_set and (name not in self._valid_enable + or name not in self._valid_disable): raise KeyError('Invalid name "{0}"'.format(name)) self._enabled.discard(name) self._disabled.discard(name) @@ -1196,13 +1197,12 @@ """ if name in self._enabled: return True - elif name in self._disabled: + if name in self._disabled: return False - elif (self._site_set or name in self._valid_enable or - name in self._valid_disable): + if (self._site_set or name in self._valid_enable + or name in self._valid_disable): return None - else: - raise KeyError('Invalid name "{0}"'.format(name)) + raise KeyError('Invalid name "{0}"'.format(name))
def __delitem__(self, name): """Remove the item by setting it to None.""" @@ -1533,10 +1533,10 @@ if name in args or name == 'self'} kwargs['parameters'] = parameters # Make sure that all arguments have remained - assert(old_kwargs | {'parameters'} == - set(kwargs) | set(kwargs['parameters'])) - assert(('parameters' in old_kwargs) is - ('parameters' in kwargs['parameters'])) + assert(old_kwargs | {'parameters'} + == set(kwargs) | set(kwargs['parameters'])) + assert(('parameters' in old_kwargs) + is ('parameters' in kwargs['parameters'])) cls._warn_kwargs() else: kwargs = dict(kwargs) @@ -2033,8 +2033,8 @@ continue # multiple warnings are in text separated by a newline for single_warning in text.splitlines(): - if (not callable(self._warning_handler) or - not self._warning_handler(mod, single_warning)): + if (not callable(self._warning_handler) + or not self._warning_handler(mod, single_warning)): pywikibot.warning('API warning ({}): {}' .format(mod, single_warning))
@@ -3347,8 +3347,8 @@
# parameters ending on 'token' should go last # wpEditToken should go very last - query.sort(key=lambda x: x[0].lower().endswith('token') + - (x[0] == 'wpEditToken')) + query.sort(key=lambda x: x[0].lower().endswith('token') + + (x[0] == 'wpEditToken')) return urlencode(query)
diff --git a/pywikibot/data/wikistats.py b/pywikibot/data/wikistats.py index a70844b..6cb1ee1 100644 --- a/pywikibot/data/wikistats.py +++ b/pywikibot/data/wikistats.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Objects representing WikiStats API.""" # -# (C) Pywikibot team, 2014-2018 +# (C) Pywikibot team, 2014-2019 # # Distributed under the terms of the MIT license. from __future__ import absolute_import, division, unicode_literals @@ -11,8 +11,9 @@
import pywikibot from pywikibot.comms import http +from pywikibot.tools import PY2
-if sys.version_info[0] > 2: +if not PY2: import csv unicode = str else: @@ -79,8 +80,8 @@ 'sourceforge', }
- ALL_TABLES = ({MISC_SITES_TABLE} | WMF_MULTILANG_TABLES | - OTHER_MULTILANG_TABLES | OTHER_TABLES) + ALL_TABLES = ({MISC_SITES_TABLE} | WMF_MULTILANG_TABLES + | OTHER_MULTILANG_TABLES | OTHER_TABLES)
ALL_KEYS = set(FAMILY_MAPPING.keys()) | ALL_TABLES
diff --git a/scripts/casechecker.py b/scripts/casechecker.py index 7f88d44..3b43a7d 100755 --- a/scripts/casechecker.py +++ b/scripts/casechecker.py @@ -373,8 +373,9 @@ src.title(with_ns=False), dst.title(with_ns=False), self.autonomous, - editSummary + ' ' + - self.MakeMoveSummary(title, newTitle), + editSummary + ' ' + + self.MakeMoveSummary(title, + newTitle), True) bot.run() else: diff --git a/scripts/flickrripper.py b/scripts/flickrripper.py index 1bd3ff5..2cc0ccc 100755 --- a/scripts/flickrripper.py +++ b/scripts/flickrripper.py @@ -18,7 +18,7 @@ """ # # (C) Multichill, 2009 -# (C) Pywikibot team, 2009-2018 +# (C) Pywikibot team, 2009-2019 # # Distributed under the terms of the MIT license. # @@ -254,9 +254,9 @@ if reviewer: description = description.replace( '{{flickrreview}}', - '{{flickrreview|' + reviewer + - '|{{subst:CURRENTYEAR}}-{{subst:CURRENTMONTH}}' - '-{{subst:CURRENTDAY2}}}}') + '{{flickrreview|%s|' + '{{subst:CURRENTYEAR}}-{{subst:CURRENTMONTH}}-' + '{{subst:CURRENTDAY2}}}}' % reviewer) if addCategory: description = description.replace('{{subst:unc}}\n', '') description = description + '\n[[Category:' + addCategory + ']]\n' diff --git a/scripts/wikisourcetext.py b/scripts/wikisourcetext.py index 9afba7a..dfe3b45 100644 --- a/scripts/wikisourcetext.py +++ b/scripts/wikisourcetext.py @@ -199,8 +199,8 @@ return page.body = _body
- if (page.exists() and - not (self.getOption('ocr') and self.getOption('force'))): + if (page.exists() + and not (self.getOption('ocr') and self.getOption('force'))): pywikibot.output('Page {} already exists, not adding!' .format(page)) else: diff --git a/tests/isbn_tests.py b/tests/isbn_tests.py index c2a409e..43bea9c 100644 --- a/tests/isbn_tests.py +++ b/tests/isbn_tests.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Tests for isbn script.""" # -# (C) Pywikibot team, 2014-2018 +# (C) Pywikibot team, 2014-2019 # # Distributed under the terms of the MIT license. # @@ -255,8 +255,8 @@ prop_page = pywikibot.PropertyPage(cls.get_repo(), claim.getID()) prop_page.get() - if ('ISBN-10' in prop_page.labels.values() and - claim.getTarget() == '097522980x'): + if ('ISBN-10' in prop_page.labels.values() + and claim.getTarget() == '097522980x'): return raise unittest.SkipTest( '{}: "ISBN-10" property was not found in ' diff --git a/tox.ini b/tox.ini index dac20c0..f830fd6 100644 --- a/tox.ini +++ b/tox.ini @@ -122,7 +122,6 @@ # P102: docstring does contain unindexed parameters # P103: other string does contain unindexed parameters # W503: line break before binary operator; against current PEP 8 recommendation -# W504 line break after binary operator
# The following are to be fixed # D102: Missing docstring in public method @@ -138,7 +137,7 @@ # D413: Missing blank line after last section # D412: No blank lines allowed between a section header and its content
-ignore = D105,D211,D401,D413,D412,FI12,FI13,FI15,FI16,FI17,FI5,H101,H236,H301,H404,H405,H903,P101,P102,P103,W503,W504 +ignore = D105,D211,D401,D413,D412,FI12,FI13,FI15,FI16,FI17,FI5,H101,H236,H301,H404,H405,H903,P101,P102,P103,W503 enable-extensions = H203,H204,H205 exclude = .tox,.git,./*.egg,ez_setup.py,build,externals,user-config.py,./scripts/i18n/*,scripts/userscripts/* min-version = 2.7
pywikibot-commits@lists.wikimedia.org