jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/474527 )
Change subject: [PEP8] Fix W504 errors in pywikibot/tests
......................................................................
[PEP8] Fix W504 errors in pywikibot/tests
Fixed the W504 error occurrences in the following files:
- tests/__init__.py
- tests/pagegenerators_tests.py
- tests/site_tests.py
- tests/tools_ip_tests.py
- tests/ui_tests.py
- tests/utils.py
Bug: T207836
Change-Id: I2798e003f9b2948e0301f5345a4aadba60d4ecc8
---
M tests/__init__.py
M tests/pagegenerators_tests.py
M tests/site_tests.py
M tests/tools_ip_tests.py
M tests/ui_tests.py
M tests/utils.py
6 files changed, 19 insertions(+), 19 deletions(-)
Approvals:
Xqt: Looks good to me, but someone else must approve
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/__init__.py b/tests/__init__.py
index d120baf..7bddc15 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -232,9 +232,9 @@
for test_func in cls:
if test_func._testMethodName not in disabled_tests[module]:
enabled_tests.append(
- module_class_name + '.' +
- test_func.__class__.__name__ + '.' +
- test_func._testMethodName)
+ module_class_name + '.'
+ + test_func.__class__.__name__ + '.'
+ + test_func._testMethodName)
test_list.extend(enabled_tests)
else:
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index 03875f5..e72d625 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -461,8 +461,8 @@
"""Test YearPageGenerator."""
site = self.get_site()
# Some languages are missing (T85681)
- if ((site.lang not in date.formats['YearBC']) or
- (site.lang not in date.formats['YearAD'])):
+ if (site.lang not in date.formats['YearBC']
+ or site.lang not in date.formats['YearAD']):
raise unittest.SkipTest(
'Date formats for this language are missing from date.py')
start = -20
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 7f6056b..5d2c369 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -699,8 +699,8 @@
for page in mysite.allpages(maxsize=200, total=5):
self.assertIsInstance(page, pywikibot.Page)
self.assertTrue(page.exists())
- if (len(page.text.encode(mysite.encoding())) > 200 and
- mysite.data_repository() == mysite):
+ if (len(page.text.encode(mysite.encoding())) > 200
+ and mysite.data_repository() == mysite):
unittest_print(
'{}.text is > 200 bytes while raw JSON is <= 200'
.format(page))
diff --git a/tests/tools_ip_tests.py b/tests/tools_ip_tests.py
index da4c1b3..e53a611 100644
--- a/tests/tools_ip_tests.py
+++ b/tests/tools_ip_tests.py
@@ -700,15 +700,15 @@
self._run_tests()
self.assertEqual(self.fail, 0)
- @expected_failure_if(ip.ip_address.__module__ == 'ipaddress' or
- ip.ip_address.__name__ == 'ip_address_patched')
+ @expected_failure_if(ip.ip_address.__module__ == 'ipaddress'
+ or ip.ip_address.__name__ == 'ip_address_patched')
def test_T76286_failures(self):
"""Test known bugs in the ipaddress module."""
self._test_T76286_failures()
self.assertEqual(self.fail, 0)
- @expected_failure_if(ip.ip_address.__module__ == 'ipaddr' and
- ip._ipaddr_version == StrictVersion('2.1.10'))
+ @expected_failure_if(ip.ip_address.__module__ == 'ipaddr'
+ and ip._ipaddr_version == StrictVersion('2.1.10'))
def test_T105443_failures(self):
"""Test known bugs in the ipaddr module."""
self._test_T105443_failures()
diff --git a/tests/ui_tests.py b/tests/ui_tests.py
index 09d1cc0..1fbe330 100644
--- a/tests/ui_tests.py
+++ b/tests/ui_tests.py
@@ -455,8 +455,8 @@
newstderr.getvalue(),
'text light purple text text ***\n')
- str2 = ('normal text \03{lightpurple} light purple ' +
- '\03{lightblue} light blue \03{previous} light purple ' +
+ str2 = ('normal text \03{lightpurple} light purple '
+ '\03{lightblue} light blue \03{previous} light purple '
'\03{default} normal text')
def testOutputColorCascade_incorrect(self):
@@ -465,8 +465,8 @@
self.assertEqual(newstdout.getvalue(), '')
self.assertEqual(
newstderr.getvalue(),
- 'normal text \x1b[95m light purple ' +
- '\x1b[94m light blue \x1b[95m light purple ' +
+ 'normal text \x1b[95m light purple '
+ '\x1b[94m light blue \x1b[95m light purple '
'\x1b[0m normal text\n')
diff --git a/tests/utils.py b/tests/utils.py
index dfd32a2..4036155 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -680,15 +680,15 @@
# Generate a more informative error
if OSWIN32 and PY2:
unicode_env = [(k, v) for k, v in os.environ.items()
- if not isinstance(k, str) or
- not isinstance(v, str)]
+ if not isinstance(k, str)
+ or not isinstance(v, str)]
if unicode_env:
raise TypeError(
'{}: unicode in os.environ: {!r}'.format(e, unicode_env))
child_unicode_env = [(k, v) for k, v in env.items()
- if not isinstance(k, str) or
- not isinstance(v, str)]
+ if not isinstance(k, str)
+ or not isinstance(v, str)]
if child_unicode_env:
raise TypeError(
'{}: unicode in child env: {!r}'
--
To view, visit https://gerrit.wikimedia.org/r/474527
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: I2798e003f9b2948e0301f5345a4aadba60d4ecc8
Gerrit-Change-Number: 474527
Gerrit-PatchSet: 2
Gerrit-Owner: Nathan fraignt <nathanklumpenaar10(a)outlook.com>
Gerrit-Reviewer: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
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/474460 )
Change subject: [PEP8] Fix W504 errors in 7 files
......................................................................
[PEP8] Fix W504 errors in 7 files
Fixed W504 errors in order to have a consistent code style.
This has the result of introducing W503 instead.
W504: unary operator at end of line.
W503: unary operator at beginning of line.
Bug: T207836
Change-Id: I9a9c255d136436b10c83571f7241544ca7e022ed
---
M docs/conf.py
M scripts/cfd.py
M scripts/imagetransfer.py
M scripts/listpages.py
M scripts/nowcommons.py
M scripts/pagefromfile.py
6 files changed, 19 insertions(+), 19 deletions(-)
Approvals:
D3r1ck01: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/conf.py b/docs/conf.py
index 14f7986..4854e2d 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -284,8 +284,8 @@
elif name == 'scripts.login' and '*' in line:
# Escape star wildcard in scripts/login.py
lines[index] = line.replace('*', '\\*')
- elif (line.endswith(':') and not line.lstrip().startswith(':') and
- 'Traceback (most recent call last)' not in line):
+ elif (line.endswith(':') and not line.lstrip().startswith(':')
+ and 'Traceback (most recent call last)' not in line):
# Initiate code block except pagegenerator arguments follows
for afterline in lines[index + 1:]:
if afterline == '':
diff --git a/scripts/cfd.py b/scripts/cfd.py
index 86f7073..e11e3c3 100755
--- a/scripts/cfd.py
+++ b/scripts/cfd.py
@@ -144,14 +144,14 @@
thisDay = findDay(src, day)
if mode == 'Move' and thisDay != 'None':
summary = (
- 'Robot - Moving category ' + src + ' to [[:Category:' +
- dest + ']] per [[WP:CFD|CFD]] at ' + thisDay + '.')
+ 'Robot - Moving category ' + src + ' to [[:Category:'
+ + dest + ']] per [[WP:CFD|CFD]] at ' + thisDay + '.')
action_summary = \
'Robot - Result of [[WP:CFD|CFD]] at ' + thisDay + '.'
elif mode == 'Speedy':
summary = (
- 'Robot - Speedily moving category ' + src +
- ' to [[:Category:' + dest + ']] per [[WP:CFDS|CFDS]].')
+ 'Robot - Speedily moving category ' + src
+ + ' to [[:Category:' + dest + ']] per [[WP:CFDS|CFDS]].')
action_summary = 'Robot - Speedily moved per [[WP:CFDS|CFDS]].'
else:
continue
diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py
index 16189ab..ae7c4dc 100755
--- a/scripts/imagetransfer.py
+++ b/scripts/imagetransfer.py
@@ -200,8 +200,8 @@
# add the nowCommons template.
pywikibot.output('Adding nowCommons template to '
+ sourceImagePage.title())
- sourceImagePage.put(sourceImagePage.get() + '\n\n' +
- nowCommonsTemplate[sourceSite.lang]
+ sourceImagePage.put(sourceImagePage.get() + '\n\n'
+ + nowCommonsTemplate[sourceSite.lang]
% targetFilename,
summary=reason)
@@ -268,9 +268,9 @@
break
todo = int(todo)
if todo in range(len(imagelist)):
- if (imagelist[todo].fileIsShared() and
- imagelist[todo].site.image_repository() ==
- self.targetSite.image_repository()):
+ if (imagelist[todo].fileIsShared()
+ and imagelist[todo].site.image_repository()
+ == self.targetSite.image_repository()):
pywikibot.output(
'The image is already shared on {0}.'
.format(self.targetSite.image_repository()))
diff --git a/scripts/listpages.py b/scripts/listpages.py
index 9675384..8b23040 100755
--- a/scripts/listpages.py
+++ b/scripts/listpages.py
@@ -157,9 +157,9 @@
"""Output formatted string."""
fmt = self.fmt_options.get(fmt, fmt)
# If selected format requires trs_title, outputlang must be set.
- if (fmt in self.fmt_need_lang or
- 'trs_title' in fmt and
- self.outputlang is None):
+ if (fmt in self.fmt_need_lang
+ or 'trs_title' in fmt
+ and self.outputlang is None):
raise ValueError(
"Required format code needs 'outputlang' parameter set.")
if num is None:
diff --git a/scripts/nowcommons.py b/scripts/nowcommons.py
index 3e7935b..5f12583 100755
--- a/scripts/nowcommons.py
+++ b/scripts/nowcommons.py
@@ -275,8 +275,8 @@
continue
commonsImagePage = pywikibot.FilePage(commons, 'Image:'
+ filenameOnCommons)
- if (localImagePage.title(with_ns=False) !=
- commonsImagePage.title(with_ns=False)):
+ if (localImagePage.title(with_ns=False)
+ != commonsImagePage.title(with_ns=False)):
usingPages = list(localImagePage.usingPages())
if usingPages and usingPages != [localImagePage]:
pywikibot.output(color_format(
diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py
index a62c801..8c1f1ec 100755
--- a/scripts/pagefromfile.py
+++ b/scripts/pagefromfile.py
@@ -153,9 +153,9 @@
return
pagecontents = page.text
nocontent = self.getOption('nocontent')
- if nocontent and (
- nocontent in pagecontents or
- nocontent.lower() in pagecontents):
+ if (nocontent
+ and (nocontent in pagecontents
+ or nocontent.lower() in pagecontents)):
pywikibot.output('Page has {0} so it is skipped'
.format(nocontent))
return
--
To view, visit https://gerrit.wikimedia.org/r/474460
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: I9a9c255d136436b10c83571f7241544ca7e022ed
Gerrit-Change-Number: 474460
Gerrit-PatchSet: 2
Gerrit-Owner: Nils ANDRE <nils.andre.chang(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
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/474469 )
Change subject: [PEP8] Fix W504 errors in pywikibot/tests
......................................................................
[PEP8] Fix W504 errors in pywikibot/tests
Fixed the W504 error occurrences in the following files:
- tests/aspects.py
- tests/dry_api_tests.py
- tests/script_tests.py
Bug: T207836
Change-Id: I6f487498539a2f204ef02b47f3417dc2ba50f721
---
M tests/aspects.py
M tests/dry_api_tests.py
M tests/script_tests.py
3 files changed, 46 insertions(+), 46 deletions(-)
Approvals:
D3r1ck01: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/aspects.py b/tests/aspects.py
index 0237885..5fcf8db 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -226,8 +226,8 @@
if skip and set(page_namespaces) != namespaces:
raise unittest.SkipTest('Pages in namespaces {!r} not found.'
- .format(list(namespaces -
- set(page_namespaces))))
+ .format(list(namespaces
+ - set(page_namespaces))))
else:
self.assertEqual(set(page_namespaces), namespaces)
@@ -333,8 +333,8 @@
if missing:
skip_decorator = unittest.skip('{0} not installed'.format(
', '.join(missing)))
- if (inspect.isclass(obj) and issubclass(obj, TestCaseBase) and
- 'nose' in sys.modules.keys()):
+ if (inspect.isclass(obj) and issubclass(obj, TestCaseBase)
+ and 'nose' in sys.modules.keys()):
# There is a known bug in nosetests which causes setUpClass()
# to be called even if the unittest class is skipped.
# Here, we decorate setUpClass() as a patch to skip it
@@ -592,8 +592,8 @@
'Set {}=1 to enable.'
.format(cls.__name__, env_var))
- if (not hasattr(site.family, 'test_codes') or
- site.code not in site.family.test_codes):
+ if (not hasattr(site.family, 'test_codes')
+ or site.code not in site.family.test_codes):
raise Exception(
'{} should only be run on test sites. '
"To run this test, add '{}' to the {} family "
@@ -735,8 +735,8 @@
for base in bases:
base_tests += [attr_name
for attr_name, attr in base.__dict__.items()
- if (attr_name.startswith('test') and
- callable(attr))]
+ if (attr_name.startswith('test')
+ and callable(attr))]
dct['abstract_class'] = not tests and not base_tests
@@ -792,8 +792,8 @@
if 'dry' in dct and dct['dry'] is True:
dct['net'] = False
- if (('sites' not in dct and 'site' not in dct) or
- ('site' in dct and not dct['site'])):
+ if (('sites' not in dct and 'site' not in dct)
+ or ('site' in dct and not dct['site'])):
# Prevent use of pywikibot.Site
bases = cls.add_base(bases, DisableSiteMixin)
@@ -850,8 +850,8 @@
dct['user'] = True
bases = cls.add_base(bases, SiteWriteMixin)
- if (('user' in dct and dct['user']) or
- ('sysop' in dct and dct['sysop'])):
+ if (('user' in dct and dct['user'])
+ or ('sysop' in dct and dct['sysop'])):
bases = cls.add_base(bases, RequireUserMixin)
for test in tests:
@@ -944,8 +944,8 @@
interface = DrySite
for data in cls.sites.values():
- if ('code' in data and data['code'] in ('test', 'mediawiki') and
- 'PYWIKIBOT_TEST_PROD_ONLY' in os.environ and not dry):
+ if ('code' in data and data['code'] in ('test', 'mediawiki')
+ and 'PYWIKIBOT_TEST_PROD_ONLY' in os.environ and not dry):
raise unittest.SkipTest(
'Site code "{}" and PYWIKIBOT_TEST_PROD_ONLY is set.'
.format(data['code']))
@@ -1011,8 +1011,8 @@
usernames = config.sysopnames if sysop else config.usernames
- return (code in usernames[family] or '*' in usernames[family] or
- code in usernames['*'] or '*' in usernames['*'])
+ return (code in usernames[family] or '*' in usernames[family]
+ or code in usernames['*'] or '*' in usernames['*'])
def __init__(self, *args, **kwargs):
"""Initializer."""
@@ -1316,8 +1316,8 @@
'{}: {!r} does not have data repository'
.format(cls.__name__, site))
- if (hasattr(cls, 'repo') and
- cls.repo != site.data_repository()):
+ if (hasattr(cls, 'repo')
+ and cls.repo != site.data_repository()):
raise Exception(
'{}: sites do not all have the same data repository'
.format(cls.__name__))
@@ -1585,8 +1585,8 @@
deprecation_messages = self.deprecation_messages
for deprecation_message in deprecation_messages:
match = self._generic_match.match(deprecation_message)
- if (match and bool(match.group(1)) == (msg is self.INSTEAD) or
- msg is None):
+ if (match and bool(match.group(1)) == (msg is self.INSTEAD)
+ or msg is None):
break
else:
self.fail('No generic deprecation message match found in '
@@ -1638,8 +1638,8 @@
def assertDeprecationFile(self, filename):
"""Assert that all deprecation warning are of one filename."""
for item in self.warning_log:
- if (self._ignore_unknown_warning_packages and
- 'pywikibot' not in item.filename):
+ if (self._ignore_unknown_warning_packages
+ and 'pywikibot' not in item.filename):
continue
if item.filename != filename:
diff --git a/tests/dry_api_tests.py b/tests/dry_api_tests.py
index 01e5dcb..f93a98c 100644
--- a/tests/dry_api_tests.py
+++ b/tests/dry_api_tests.py
@@ -222,8 +222,8 @@
req = CachedRequest(expiry=1, site=self.mocksite,
parameters={'action': 'query', 'meta': 'siteinfo'})
- expect = ('MockSite()User(User:محمد الفلسطيني)' +
- "[('action', 'query'), ('meta', 'siteinfo')]")
+ expect = ('MockSite()User(User:محمد الفلسطيني)'
+ + "[('action', 'query'), ('meta', 'siteinfo')]")
self.assertEqual(repr(req._uniquedescriptionstr()), repr(expect))
diff --git a/tests/script_tests.py b/tests/script_tests.py
index 1bca38e..6d4ef3e 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -66,15 +66,15 @@
def list_scripts(path, exclude=None):
"""Return list of scripts in given path."""
scripts = [name[0:-3] for name in os.listdir(path) # strip '.py'
- if name.endswith('.py') and
- not name.startswith('_') and # skip __init__.py and _*
- name != exclude]
+ if name.endswith('.py')
+ and not name.startswith('_') # skip __init__.py and _*
+ and name != exclude]
return scripts
-script_list = (['login'] +
- list_scripts(scripts_path, 'login.py') +
- list_scripts(archive_path))
+script_list = (['login']
+ + list_scripts(scripts_path, 'login.py')
+ + list_scripts(archive_path))
runnable_script_list = (
['login'] + sorted(set(script_list) - {'login'} - unrunnable_script_set))
@@ -184,24 +184,24 @@
'(set PYWIKIBOT_TEST_AUTORUN=1 to enable):\n {!r}'
.format(auto_run_script_list))
- tests = (['test__login'] +
- ['test_' + name
- for name in sorted(script_list)
- if name != 'login'
- and name not in unrunnable_script_set
- ])
+ tests = (['test__login']
+ + ['test_' + name
+ for name in sorted(script_list)
+ if name != 'login'
+ and name not in unrunnable_script_set
+ ])
test_list = ['tests.script_tests.TestScriptHelp.' + name
for name in tests]
- tests = (['test__login'] +
- ['test_' + name
- for name in sorted(script_list)
- if name != 'login'
- and name not in failed_dep_script_set
- and name not in unrunnable_script_set
- and (enable_autorun_tests or name not in auto_run_script_list)
- ])
+ tests = (['test__login']
+ + ['test_' + name
+ for name in sorted(script_list)
+ if name != 'login'
+ and name not in failed_dep_script_set
+ and name not in unrunnable_script_set
+ and (enable_autorun_tests or name not in auto_run_script_list)
+ ])
test_list += ['tests.script_tests.TestScriptSimulate.' + name
for name in tests]
@@ -225,8 +225,8 @@
def __new__(cls, name, bases, dct):
"""Create the new class."""
def test_execution(script_name, args=[]):
- is_autorun = ('-help' not in args and
- script_name in auto_run_script_list)
+ is_autorun = ('-help' not in args
+ and script_name in auto_run_script_list)
def test_skip_script(self):
raise unittest.SkipTest(
--
To view, visit https://gerrit.wikimedia.org/r/474469
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: I6f487498539a2f204ef02b47f3417dc2ba50f721
Gerrit-Change-Number: 474469
Gerrit-PatchSet: 5
Gerrit-Owner: Nathan fraignt <nathanklumpenaar10(a)outlook.com>
Gerrit-Reviewer: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
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/474523 )
Change subject: [bugfix] Use a copy of failed_dep_script_set for _expected_failures
......................................................................
[bugfix] Use a copy of failed_dep_script_set for _expected_failures
failed_dep_script_set is a mutable. Assigning it to _expected_failures and
modifying _expected_failures also modifies failed_dep_script_set's content
because _expected_failures is just a reference and using
failed_dep_script_set with the next class it unexpectly uses the modified
content and tests may fail.
Therefore use a copy.
Bug: T209762
Change-Id: I2df96be60b9aaaf462f843a6fd6b2d9e0b33368e
---
M tests/script_tests.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/script_tests.py b/tests/script_tests.py
index 1bca38e..9018535 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -374,7 +374,7 @@
net = False
- _expected_failures = failed_dep_script_set
+ _expected_failures = set(failed_dep_script_set) # use a copy
# -help tests may pass even when packages are required
_expected_failures.discard('flickrripper')
_expected_failures.discard('imageharvest')
--
To view, visit https://gerrit.wikimedia.org/r/474523
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: I2df96be60b9aaaf462f843a6fd6b2d9e0b33368e
Gerrit-Change-Number: 474523
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/474479 )
Change subject: [PEP8] Fix W504 errors in 3 files
......................................................................
[PEP8] Fix W504 errors in 3 files
Fixed W504 errors in order to have a consistent code style.
This has the consequence of introducing W503 instead.
W504: unary operator at end of line.
W503: unary operator at beginning of line.
Bug: T207836
Change-Id: If6de53d4badfd8e533a56d591aeedff53c8ce975
---
M scripts/casechecker.py
M scripts/solve_disambiguation.py
M scripts/table2wiki.py
3 files changed, 19 insertions(+), 19 deletions(-)
Approvals:
Framawiki: Looks good to me, but someone else must approve
Dvorapa: Looks good to me, but someone else must approve
D3r1ck01: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/casechecker.py b/scripts/casechecker.py
index 51c4904..edce6e7 100755
--- a/scripts/casechecker.py
+++ b/scripts/casechecker.py
@@ -523,8 +523,8 @@
c2 = self.lclToLatDict[co]
else:
c2 = None
- kw = [w for w in kw if p < len(w) and
- (w[p] == c or (c2 is not None and w[p] == c2))]
+ kw = [w for w in kw if p < len(w)
+ and (w[p] == c or (c2 is not None and w[p] == c2))]
if len(kw) > 1:
pywikibot.output("Word '{}' could be treated as more than "
'one known words'.format(badWord))
diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py
index 378e921..c831bb8 100755
--- a/scripts/solve_disambiguation.py
+++ b/scripts/solve_disambiguation.py
@@ -867,8 +867,8 @@
# how many bytes should be displayed around the current link
context = 60
# check if there's a dn-template here already
- if (self.dnSkip and self.dn_template_str and
- self.dn_template_str[:-2] in text[
+ if (self.dnSkip and self.dn_template_str
+ and self.dn_template_str[:-2] in text[
m.end():m.end() + len(self.dn_template_str) + 8]):
continue
@@ -952,9 +952,9 @@
else:
position_split = 0
# insert dab needed template
- text = (text[:m.end() + position_split] +
- self.dn_template_str +
- text[m.end() + position_split:])
+ text = (text[:m.end() + position_split]
+ + self.dn_template_str
+ + text[m.end() + position_split:])
dn = True
continue
elif answer == 'u':
@@ -995,12 +995,12 @@
# check if we can create a link with trailing characters
# instead of a pipelink
elif (
- (len(new_page_title) <= len(link_text)) and
- (firstcap(link_text[:len(new_page_title)]) ==
- firstcap(new_page_title)) and
- (self.trailR.sub(
- '', link_text[len(new_page_title):]) == '') and
- (not section)
+ (len(new_page_title) <= len(link_text))
+ and (firstcap(link_text[:len(new_page_title)])
+ == firstcap(new_page_title))
+ and (self.trailR.sub(
+ '', link_text[len(new_page_title):]) == '')
+ and (not section)
):
newlink = '[[{0}]]{1}'.format(
link_text[:len(new_page_title)],
@@ -1133,8 +1133,8 @@
'solve_disambiguation-unknown-page')
# first check whether user has customized the edit comment
- if (self.mysite.family.name in config.disambiguation_comment and
- self.mylang in config.disambiguation_comment[
+ if (self.mysite.family.name in config.disambiguation_comment
+ and self.mylang in config.disambiguation_comment[
self.mysite.family.name]):
try:
self.comment = i18n.translate(
diff --git a/scripts/table2wiki.py b/scripts/table2wiki.py
index 91bd44e..8cc47ad 100644
--- a/scripts/table2wiki.py
+++ b/scripts/table2wiki.py
@@ -426,8 +426,8 @@
'More opening than closing table tags. Skipping.')
return None, 0, 0
# if another table tag is opened before one is closed
- elif (next_starting and
- next_starting.start() < next_ending.start()):
+ elif (next_starting
+ and next_starting.start() < next_ending.start()):
offset += next_starting.end()
text = text[next_starting.end():]
depth += 1
@@ -508,8 +508,8 @@
{'count': warnings}
)
self.put_current(new_text, summary=edit_summary,
- show_diff=not (self.getOption('quiet') and
- self.getOption('always')))
+ show_diff=not (self.getOption('quiet')
+ and self.getOption('always')))
_marked_table_start_search = re.compile('<##table##', re.IGNORECASE).search
--
To view, visit https://gerrit.wikimedia.org/r/474479
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: If6de53d4badfd8e533a56d591aeedff53c8ce975
Gerrit-Change-Number: 474479
Gerrit-PatchSet: 1
Gerrit-Owner: Nils ANDRE <nils.andre.chang(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/474471 )
Change subject: [FIX] Any environment variable added on Windows must be of type str on py 2
......................................................................
[FIX] Any environment variable added on Windows must be of type str on py 2
Bug: T209767
Change-Id: Ia597b396b007e4299a864f8337238bff823b5ac6
---
M tests/utils.py
1 file changed, 4 insertions(+), 1 deletion(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/utils.py b/tests/utils.py
index ff13b92..dfd32a2 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -643,7 +643,10 @@
'please update your Python.'))
# Any environment variables added on Windows must be of type
# str() on Python 2.
- env = os.environ.copy()
+ if OSWIN32 and PY2:
+ env = {str(k): str(v) for k, v in os.environ.items()}
+ else:
+ env = os.environ.copy()
# Prevent output by test package; e.g. 'max_retries reduced from x to y'
env[str('PYWIKIBOT_TEST_QUIET')] = str('1')
--
To view, visit https://gerrit.wikimedia.org/r/474471
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: Ia597b396b007e4299a864f8337238bff823b5ac6
Gerrit-Change-Number: 474471
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: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
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))
--
To view, visit https://gerrit.wikimedia.org/r/474126
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: If2454a8aa89485ea1b3a380d1f2824f5cee27519
Gerrit-Change-Number: 474126
Gerrit-PatchSet: 5
Gerrit-Owner: Stibba <stevenvandenwildenberg(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/462912 )
Change subject: [tests] Run L10N tests on Travis only once for each patch
......................................................................
[tests] Run L10N tests on Travis only once for each patch
- Introduce an new environment variable "PYWIKIBOT_NO_L10N_TESTS"
- Skip L10N tests if "PYWIKIBOT_NO_L10N_TESTS" is set during Travis test
- Reset the new "PYWIKIBOT_NO_L10N_TESTS" environment in Travis test matrix
for a test which consumes lowest test time
Bug: T191632
Change-Id: I681b77232128d11bb908ff607102dbda255029b6
---
M .travis.yml
M tests/l10n_tests.py
2 files changed, 10 insertions(+), 1 deletion(-)
Approvals:
Dvorapa: Looks good to me, but someone else must approve
Framawiki: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.travis.yml b/.travis.yml
index 30e5218..f6bf164 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -122,6 +122,7 @@
env:
global:
- TEST_TIMEOUT=300
+ - PYWIKIBOT_NO_L10N_TESTS=1
matrix:
- LANGUAGE=en FAMILY=wikipedia PYWIKIBOT_TEST_PROD_ONLY=1
@@ -145,7 +146,7 @@
- python: '3.6'
env: LANGUAGE=zh FAMILY=wpbeta SITE_ONLY=1 OAUTH_DOMAIN="zh.wikipedia.beta.wmflabs.org"
- python: '3.4'
- env: LANGUAGE=en FAMILY=wsbeta SITE_ONLY=1
+ env: LANGUAGE=en FAMILY=wsbeta SITE_ONLY=1 PYWIKIBOT_NO_L10N_TESTS=0
- python: '2.7'
env: LANGUAGE=wikia FAMILY=wikia PYWIKIBOT_TEST_NO_RC=1
- python: '3.5'
diff --git a/tests/l10n_tests.py b/tests/l10n_tests.py
index 2e4f26d..6c2ae31 100644
--- a/tests/l10n_tests.py
+++ b/tests/l10n_tests.py
@@ -7,6 +7,8 @@
#
from __future__ import absolute_import, division, unicode_literals
+import os
+
import pywikibot
from pywikibot import i18n
from pywikibot.textlib import extract_templates_and_params_regex_simple
@@ -110,6 +112,12 @@
.format(package, key))
+def setUpModule(): # noqa: N802
+ """Skip Travis tests if PYWIKIBOT_NO_L10N_TESTS variable is set."""
+ if os.environ.get('PYWIKIBOT_NO_L10N_TESTS', '0') == '1':
+ raise unittest.SkipTest('L10N tests disabled.')
+
+
if __name__ == '__main__': # pragma: no cover
try:
unittest.main()
--
To view, visit https://gerrit.wikimedia.org/r/462912
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: I681b77232128d11bb908ff607102dbda255029b6
Gerrit-Change-Number: 462912
Gerrit-PatchSet: 8
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)