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
--
To view, visit https://gerrit.wikimedia.org/r/487476
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: I28973b22f0d45c0761520c4b5595d03ed21ebe43
Gerrit-Change-Number: 487476
Gerrit-PatchSet: 8
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
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/490290 )
Change subject: [tests] Fix site_tests.TestLogPages tests
......................................................................
[tests] Fix site_tests.TestLogPages tests
test_logpages and test_list_namespace are sometimes failing due to
autoblock removal entries. Check for this case.
Bug: T216002
Change-Id: I3a19f62a7610cc04da28e5fcbdeda0f2614c2f78
---
M tests/site_tests.py
1 file changed, 4 insertions(+), 1 deletion(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 9b5424b..211f0e8 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -1353,7 +1353,8 @@
self.assertLessEqual(len(le), 10)
for entry in le:
self.assertIsInstance(entry, tuple)
- self.assertIsInstance(entry[0], pywikibot.Page)
+ if not isinstance(entry[0], int): # autoblock removal entry
+ self.assertIsInstance(entry[0], pywikibot.Page)
self.assertIsInstance(entry[1], basestring)
self.assertIsInstance(
entry[2], long if PY2 and entry[2] > sys.maxint else int)
@@ -1363,6 +1364,8 @@
"""Test the deprecated site.logpages() when namespace is a list."""
le = list(self.site.logpages(namespace=[2, 3], number=10))
for entry in le:
+ if isinstance(entry[0], int): # autoblock removal entry
+ continue
try:
self.assertIn(entry[0].namespace(), [2, 3])
except HiddenKeyError as e:
--
To view, visit https://gerrit.wikimedia.org/r/490290
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: I3a19f62a7610cc04da28e5fcbdeda0f2614c2f78
Gerrit-Change-Number: 490290
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
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/489793 )
Change subject: proofreadpage: skip tests if ws_ocr_daemon is not running
......................................................................
proofreadpage: skip tests if ws_ocr_daemon is not running
Skip tests if ws_ocr_daemon robot is not running.
Bug: T215733
Change-Id: I4019461589958f21954d48df00c2c1f42a9d5815
---
M tests/proofreadpage_tests.py
1 file changed, 10 insertions(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/proofreadpage_tests.py b/tests/proofreadpage_tests.py
index ee0b134..92feab5 100644
--- a/tests/proofreadpage_tests.py
+++ b/tests/proofreadpage_tests.py
@@ -344,6 +344,7 @@
'the year 1572,\nBY D. APPLETON & CO.\n'
'In the Office of the Librarian of '
'Congress, at Washington.\n4 334\n'),
+ 'ws_ocr_daemon_msg': 'ws_ocr_daemon robot is not running.',
}
def setUp(self):
@@ -374,10 +375,19 @@
response = http.fetch(uri)
self.assertEqual(response.status, 200)
+ # Check that ws_ocr_daemon robot is running, otherwise skip test.
+ data = json.loads(response.text)
+ if data['text'].startswith(self.data['ws_ocr_daemon_msg']):
+ self.skipTest(self.data['ws_ocr_daemon_msg'])
+
def test_do_ocr_phetools(self):
"""Test page._do_ocr(ocr_tool='phetools')."""
error, text = self.page._do_ocr(ocr_tool='phetools')
ref_error, ref_text = self.data['ocr']
+
+ # Check that ws_ocr_daemon robot is running, otherwise skip test.
+ if text.startswith(self.data['ws_ocr_daemon_msg']):
+ self.skipTest(self.data['ws_ocr_daemon_msg'])
self.assertEqual(error, ref_error)
self.assertEqual(text, ref_text)
--
To view, visit https://gerrit.wikimedia.org/r/489793
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: I4019461589958f21954d48df00c2c1f42a9d5815
Gerrit-Change-Number: 489793
Gerrit-PatchSet: 3
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)