jenkins-bot submitted this change.

View Change

Approvals: Matěj Suchánek: Looks good to me, approved jenkins-bot: Verified
[IMPR] Simplify comparing empty sequences

Change-Id: I80fa74ea1f2c29cb121b723fc0e20594a124a90a
---
M pywikibot/page/__init__.py
M pywikibot/tools/__init__.py
M scripts/checkimages.py
M scripts/weblinkchecker.py
M scripts/welcome.py
M tests/pagegenerators_tests.py
M tests/site_tests.py
7 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index 19fc629..6a071b5 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -851,7 +851,7 @@
disambigs.update(self.site._disambigtemplates)
# see if any template on this page is in the set of disambigs
disambig_in_page = disambigs.intersection(templates)
- return self.namespace() != 10 and len(disambig_in_page) > 0
+ return self.namespace() != 10 and disambig_in_page

@deprecated_args(withTemplateInclusion='with_template_inclusion',
onlyTemplateInclusion='only_template_inclusion',
@@ -4565,7 +4565,7 @@
if hasattr(self, 'hash') and self.hash is not None:
data['hash'] = self.hash
else:
- if len(self.qualifiers) > 0:
+ if self.qualifiers:
data['qualifiers'] = {}
data['qualifiers-order'] = list(self.qualifiers.keys())
for prop, qualifiers in self.qualifiers.items():
@@ -4573,7 +4573,8 @@
assert qualifier.isQualifier is True
data['qualifiers'][prop] = [
qualifier.toJSON() for qualifier in qualifiers]
- if len(self.sources) > 0:
+
+ if self.sources:
data['references'] = []
for collection in self.sources:
reference = {
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 2274554..54ace92 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -1357,8 +1357,7 @@

since = kwargs.pop('since', None)
future_warning = kwargs.pop('future_warning', False)
- without_parameters = (len(args) == 1 and len(kwargs) == 0
- and callable(args[0]))
+ without_parameters = len(args) == 1 and not kwargs and callable(args[0])
if 'instead' in kwargs:
instead = kwargs['instead']
elif not without_parameters and len(args) == 1:
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index cde33f7..aaeba52 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -943,7 +943,7 @@
self.report(text_for_the_report, image_to_tag,
commImage=dupComment_image, unver=True)

- if len(images_to_tag_list) != 0 and not only_report:
+ if images_to_tag_list and not only_report:
fp = pywikibot.FilePage(self.site, images_to_tag_list[-1])
already_reported_in_past = fp.revision_count(self.bots)
from_regex = (r'\n\*\[\[:%s%s\]\]'
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py
index 9670077..192fc9f 100755
--- a/scripts/weblinkchecker.py
+++ b/scripts/weblinkchecker.py
@@ -491,7 +491,7 @@
def run(self):
"""Run thread."""
while not self.killed:
- if len(self.queue) == 0:
+ if not self.queue:
if self.finishing:
break
time.sleep(0.1)
diff --git a/scripts/welcome.py b/scripts/welcome.py
index f03fa4d..99fb090 100755
--- a/scripts/welcome.py
+++ b/scripts/welcome.py
@@ -901,7 +901,7 @@
"""Load the badword list and the whitelist."""
page = re.compile(r'(?:\"|\')(.*?)(?:\"|\')(?:, |\))')
list_loaded = page.findall(raw)
- if len(list_loaded) == 0:
+ if not list_loaded:
pywikibot.output('There was no input on the real-time page.')
return list_loaded

diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index 5bf1bec..0b6d4e0 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -1495,7 +1495,7 @@
super().setUpClass()
site = pywikibot.Site()
newuser_logevents = list(site.logevents(logtype='newusers', total=1))
- if len(newuser_logevents) == 0:
+ if not newuser_logevents:
raise unittest.SkipTest('No newuser logs found to test with.')

login = True
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 2e6c595..d39ee83 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -410,11 +410,11 @@
def test_categorymembers(self):
"""Test Site.categorymembers."""
cats = list(self.site.pagecategories(self.mainpage))
- if len(cats) == 0:
+ if not cats:
self.skipTest('Main page is not in any categories.')
- else:
- for cm in self.site.categorymembers(cats[0]):
- self.assertIsInstance(cm, pywikibot.Page)
+
+ for cm in self.site.categorymembers(cats[0]):
+ self.assertIsInstance(cm, pywikibot.Page)

def test_pageimages(self):
"""Test Site.pageimages."""

To view, visit change 674583. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I80fa74ea1f2c29cb121b723fc0e20594a124a90a
Gerrit-Change-Number: 674583
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged