jenkins-bot submitted this change.
[pep8] Line break before a binary operator
https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator
Change-Id: I93cace7af67502d6096fa165ffc9023535fea40b
---
M pywikibot/__init__.py
M pywikibot/bot_choice.py
M pywikibot/cosmetic_changes.py
M pywikibot/data/api.py
M pywikibot/family.py
M pywikibot/page/__init__.py
M pywikibot/site/_apisite.py
M pywikibot/site/_basesite.py
M pywikibot/textlib.py
M pywikibot/version.py
M scripts/category.py
M scripts/download_dump.py
M scripts/noreferences.py
M scripts/weblinkchecker.py
M tests/wikibase_tests.py
15 files changed, 63 insertions(+), 66 deletions(-)
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 08d50ef..76d3fe2 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -706,8 +706,8 @@
self.site = site or Site().data_repository()
# also allow entity URIs to be provided via unit parameter
- if isinstance(unit, str) and \
- unit.partition('://')[0] not in ('http', 'https'):
+ if isinstance(unit, str) \
+ and unit.partition('://')[0] not in ('http', 'https'):
raise ValueError("'unit' must be an ItemPage or entity uri.")
if error is None and not self._require_errors(site):
@@ -905,8 +905,8 @@
# pcre regexp: '/^Data:[^\\[\\]#\\\:{|}]+\.tab$/u' for tabular-data
# As we have already checked for existence the following simplified
# check should be enough.
- if not page.title().startswith('Data:') or \
- not page.title().endswith(ending):
+ if not page.title().startswith('Data:') \
+ or not page.title().endswith(ending):
raise ValueError(
"Page must be in 'Data:' namespace and end in '{0}' "
'for {1}.'.format(ending, label))
diff --git a/pywikibot/bot_choice.py b/pywikibot/bot_choice.py
index 8a9a661..9c2601d 100755
--- a/pywikibot/bot_choice.py
+++ b/pywikibot/bot_choice.py
@@ -286,8 +286,8 @@
if self.replacer.current_link.anchor is None:
kwargs['label'] = self.replacer.current_groups['title']
if self.replacer.current_groups['section']:
- kwargs['label'] += '#' + \
- self.replacer.current_groups['section']
+ kwargs['label'] += '#' \
+ + self.replacer.current_groups['section']
else:
kwargs['label'] = self.replacer.current_link.anchor
return pywikibot.Link.create_separated(
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index d8ea03b..97bbfe3 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -51,7 +51,7 @@
'your_script_name_2']
"""
#
-# (C) Pywikibot team, 2006-2020
+# (C) Pywikibot team, 2006-2021
#
# Distributed under the terms of the MIT license.
#
@@ -801,8 +801,8 @@
exceptions = ['comment', 'math', 'nowiki', 'pre']
builder = _MultiTemplateMatchBuilder(self.site)
- if self.site.family.name in deprecatedTemplates and \
- self.site.code in deprecatedTemplates[self.site.family.name]:
+ if self.site.family.name in deprecatedTemplates \
+ and self.site.code in deprecatedTemplates[self.site.family.name]:
for template in deprecatedTemplates[
self.site.family.name][self.site.code]:
old, new = template
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 4c34108..ae28af0 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -490,8 +490,8 @@
break
else:
param = {}
- assert param['name'] == 'generator' and \
- submodules >= set(param['type'])
+ assert param['name'] == 'generator' \
+ and submodules >= set(param['type'])
def _normalize_modules(self, modules) -> set:
"""Add query+ to any query module name not also in action modules."""
@@ -1846,8 +1846,8 @@
continue
# Phab. tickets T48535, T64126, T68494, T68619
- if code == 'failed-save' and \
- self._is_wikibase_error_retryable(result['error']):
+ if code == 'failed-save' \
+ and self._is_wikibase_error_retryable(result['error']):
self.wait()
continue
@@ -2147,13 +2147,15 @@
n = 0
while True:
self.request[self.continue_name] = offset
- pywikibot.debug('%s: Request: %s' % (
- self.__class__.__name__, self.request), _logger)
+ pywikibot.debug('{}: Request: {}'
+ .format(self.__class__.__name__, self.request),
+ _logger)
data = self.request.submit()
n_items = len(data[self.data_name])
- pywikibot.debug('%s: Retrieved %d items' % (
- self.__class__.__name__, n_items), _logger)
+ pywikibot.debug('{}: Retrieved {} items'
+ .format(self.__class__.__name__, n_items),
+ _logger)
if n_items > 0:
for item in data[self.data_name]:
yield item
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 853be17..262c8c0 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -619,8 +619,8 @@
def category_redirects(self, code, fallback='_default'):
"""Return list of category redirect templates."""
- if not hasattr(self, '_catredirtemplates') or \
- code not in self._catredirtemplates:
+ if not hasattr(self, '_catredirtemplates') \
+ or code not in self._catredirtemplates:
self._get_cr_templates(code, fallback)
return self._catredirtemplates[code]
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index 009aeb6..f0585c5 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -293,14 +293,14 @@
else:
target_code = config.mylang
target_family = config.family
- if force_interwiki or \
- (allow_interwiki
- and (self.site.family.name != target_family
- or self.site.code != target_code)):
+ if force_interwiki \
+ or (allow_interwiki
+ and (self.site.family.name != target_family
+ or self.site.code != target_code)):
if self.site.family.name != target_family \
and self.site.family.name != self.site.code:
- title = '%s:%s:%s' % (
- self.site.family.name, self.site.code, title)
+ title = '{site.family.name}:{site.code}:{title}'.format(
+ site=self.site, title=title)
else:
# use this form for sites like commons, where the
# code is the same as the family name
@@ -5344,13 +5344,11 @@
# often be unreachable due to the way web browsers deal
# * with 'relative' URLs. Forbid them explicitly.
- if '.' in t and (
- t in ('.', '..')
- or t.startswith(('./', '../'))
- or '/./' in t
- or '/../' in t
- or t.endswith(('/.', '/..'))
- ):
+ if '.' in t and (t in ('.', '..')
+ or t.startswith(('./', '../'))
+ or '/./' in t
+ or '/../' in t
+ or t.endswith(('/.', '/..'))):
raise pywikibot.InvalidTitle(
"(contains . / combinations): '%s'"
% self._text)
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 72e4325..196bffc 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -4509,8 +4509,8 @@
# TODO: catch and process foreseeable errors
if error.code == 'uploaddisabled':
self._uploaddisabled = True
- elif error.code == 'stashfailed' and \
- 'offset' in error.other:
+ elif error.code == 'stashfailed' \
+ and 'offset' in error.other:
# TODO: Ask MediaWiki to change this
# ambiguous error code.
diff --git a/pywikibot/site/_basesite.py b/pywikibot/site/_basesite.py
index e866e06..a46bc22 100644
--- a/pywikibot/site/_basesite.py
+++ b/pywikibot/site/_basesite.py
@@ -76,11 +76,11 @@
pywikibot.log('Site %s instantiated and marked "obsolete" '
'to prevent access' % self)
elif self.__code not in self.languages():
- if self.__family.name in self.__family.langs and \
- len(self.__family.langs) == 1:
+ if self.__family.name in self.__family.langs \
+ and len(self.__family.langs) == 1:
self.__code = self.__family.name
if self.__family == pywikibot.config.family \
- and code == pywikibot.config.mylang:
+ and code == pywikibot.config.mylang:
pywikibot.config.mylang = self.__code
warn('Global configuration variable "mylang" changed to '
'"%s" while instantiating site %s'
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 9df6e0c..7d15da6 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -1094,11 +1094,10 @@
separator=separatorstripped)
s = interwikiFormat(new, insite=site)
if s:
- if site.code in site.family.interwiki_attop or \
- '<!-- interwiki at top -->' in oldtext:
+ if site.code in site.family.interwiki_attop \
+ or '<!-- interwiki at top -->' in oldtext:
# do not add separator if interwiki links are on one line
- newtext = s + ('' if site.code
- in site.family.interwiki_on_one_line
+ newtext = s + ('' if site.code in site.family.interwiki_on_one_line
else separator) + s2.replace(marker, '').strip()
else:
# calculate what was after the language links on the page
@@ -1116,8 +1115,8 @@
elif site.code in site.family.categories_last:
cats = getCategoryLinks(s2, site=site)
s2 = removeCategoryLinksAndSeparator(
- s2.replace(marker, cseparatorstripped).strip(), site) + \
- separator + s
+ s2.replace(marker, cseparatorstripped).strip(), site) \
+ + separator + s
newtext = replaceCategoryLinks(s2, cats, site=site,
addOnly=True)
# for Wikitravel's language links position.
diff --git a/pywikibot/version.py b/pywikibot/version.py
index 5667630..20242f5 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -480,8 +480,8 @@
# If builtins or standard_lib is None,
# only include package if a version was found.
- if (builtins is None and name in builtin_packages) or \
- (standard_lib is None and name in std_lib_packages):
+ if builtins is None and name in builtin_packages \
+ or standard_lib is None and name in std_lib_packages:
if 'ver' in info:
data[name] = info
else:
diff --git a/scripts/category.py b/scripts/category.py
index cc868a0..e5876f9 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -710,8 +710,8 @@
else:
pywikibot.log("Didn't move pages/subcategories, because the "
"category page hasn't been moved.")
- if self.oldcat.isEmptyCategory() and self.delete_oldcat and \
- ((self.newcat and self.move_oldcat) or not self.newcat):
+ if self.oldcat.isEmptyCategory() and self.delete_oldcat \
+ and (self.newcat and self.move_oldcat or not self.newcat):
self._delete(can_move_page, can_move_talk)
def _delete(self, moved_page, moved_talk) -> None:
diff --git a/scripts/download_dump.py b/scripts/download_dump.py
index 98517fa..4f38605 100755
--- a/scripts/download_dump.py
+++ b/scripts/download_dump.py
@@ -78,8 +78,8 @@
download_filename = '{wikiname}-{dumpdate}-{filename}'.format_map(
self.opt)
- temp_filename = download_filename + '-' + \
- binascii.b2a_hex(urandom(8)).decode('ascii') + '.part'
+ temp_filename = download_filename + '-' \
+ + binascii.b2a_hex(urandom(8)).decode('ascii') + '.part'
file_final_storepath = os.path.join(
self.opt.storepath, download_filename)
diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index 20407cc..49fd0f0 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -29,7 +29,7 @@
a list of affected articles
"""
#
-# (C) Pywikibot team, 2007-2020
+# (C) Pywikibot team, 2007-2021
#
# Distributed under the terms of the MIT license.
#
@@ -542,8 +542,8 @@
def lacksReferences(self, text) -> bool:
"""Check whether or not the page is lacking a references tag."""
oldTextCleaned = textlib.removeDisabledParts(text)
- if self.referencesR.search(oldTextCleaned) or \
- self.referencesTagR.search(oldTextCleaned):
+ if self.referencesR.search(oldTextCleaned) \
+ or self.referencesTagR.search(oldTextCleaned):
if self.opt.verbose:
pywikibot.output('No changes necessary: references tag found.')
return False
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py
index de3885e..ecc2836 100755
--- a/scripts/weblinkchecker.py
+++ b/scripts/weblinkchecker.py
@@ -104,7 +104,7 @@
python pwb.py weblinkchecker -repeat
"""
#
-# (C) Pywikibot team, 2005-2020
+# (C) Pywikibot team, 2005-2021
#
# Distributed under the terms of the MIT license.
#
@@ -517,11 +517,9 @@
content = ''
if archiveURL:
- archiveMsg = '\n' + \
- i18n.twtranslate(
- containingPage.site,
- 'weblinkchecker-archive_msg',
- {'URL': archiveURL})
+ archiveMsg = '\n' + i18n.twtranslate(
+ containingPage.site, 'weblinkchecker-archive_msg',
+ {'URL': archiveURL})
else:
archiveMsg = ''
# The caption will default to "Dead link". But if there
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index 9f19a85..4413ffe 100644
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -690,8 +690,8 @@
"""Test WbGeoShape error handling of a non-map page."""
non_data_page = Page(self.commons, 'File:Foo.jpg')
non_map_page = Page(self.commons, 'Data:TemplateData/TemplateData.tab')
- regex = r"^Page must be in 'Data:' namespace and end in '\.map' " + \
- r'for geo-shape\.$'
+ regex = (r"^Page must be in 'Data:' namespace and end in '\.map' "
+ r'for geo-shape\.$')
with self.assertRaisesRegex(ValueError, regex):
pywikibot.WbGeoShape(non_data_page, self.get_repo())
with self.assertRaisesRegex(ValueError, regex):
@@ -766,8 +766,8 @@
"""Test WbTabularData error handling of a non-map page."""
non_data_page = Page(self.commons, 'File:Foo.jpg')
non_map_page = Page(self.commons, 'Data:Lyngby Hovedgade.map')
- regex = r"^Page must be in 'Data:' namespace and end in '\.tab' " + \
- r'for tabular-data\.$'
+ regex = (r"^Page must be in 'Data:' namespace and end in '\.tab' "
+ r'for tabular-data\.$')
with self.assertRaisesRegex(ValueError, regex):
pywikibot.WbTabularData(non_data_page, self.get_repo())
with self.assertRaisesRegex(ValueError, regex):
@@ -1251,8 +1251,8 @@
"""Test ItemPage.from_entity_uri with unexpected item repo."""
repo = self.get_repo()
entity_uri = 'http://test.wikidata.org/entity/Q124'
- regex = r'^The supplied data repository \(.+\) does not ' + \
- r'correspond to that of the item \(.+\)$'
+ regex = (r'^The supplied data repository \(.+\) does not '
+ r'correspond to that of the item \(.+\)$')
with self.assertRaisesRegex(ValueError, regex):
ItemPage.from_entity_uri(repo, entity_uri)
@@ -2028,8 +2028,8 @@
"""Test that page_from_repository method fails."""
site = self.get_site(key)
dummy_item = 'Q1'
- regex = r'^page_from_repository method is not implemented ' + \
- r'for Wikibase .+\.$'
+ regex = (r'^page_from_repository method is not implemented '
+ r'for Wikibase .+\.$')
with self.assertRaisesRegex(NotImplementedError, regex):
site.page_from_repository(dummy_item)
To view, visit change 669096. To unsubscribe, or for help writing mail filters, visit settings.