jenkins-bot submitted this change.

View Change


Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
Use append instead of list concatenation

Do not create an object in memory that is
immediately thrown away.

Change-Id: I29f521671b5b4da990d8579d95bf4f9127d2b4d9
---
M pywikibot/scripts/login.py
M pywikibot/textlib.py
M scripts/upload.py
M pywikibot/page/_category.py
M pywikibot/cosmetic_changes.py
M pywikibot/site/_siteinfo.py
M pywikibot/diff.py
M pywikibot/userinterfaces/terminal_interface_base.py
M pywikibot/i18n.py
M scripts/listpages.py
M pywikibot/site/_upload.py
11 files changed, 34 insertions(+), 22 deletions(-)

diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index 9235462..bf0063c 100644
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -667,8 +667,8 @@
8207, # Right-to-left mark (&rtl;)
]
if self.template:
- ignore += [32] # Space ( )
- ignore += [58] # Colon (:)
+ ignore.append(32) # Space ( )
+ ignore.append(58) # Colon (:)
# TODO: T254350 - what other extension tags should be avoided?
# (graph, math, score, timeline, etc.)
text = pywikibot.html2unicode(
diff --git a/pywikibot/diff.py b/pywikibot/diff.py
index 117b6dd..fa99103 100644
--- a/pywikibot/diff.py
+++ b/pywikibot/diff.py
@@ -348,10 +348,10 @@
# created with one hunk
if (not super_hunk or hunk.pre_context <= self.context * 2):
# previous hunk has shared/adjacent self.context lines
- super_hunk += [hunk]
+ super_hunk.append(hunk)
else:
super_hunk = [hunk]
- super_hunks += [super_hunk]
+ super_hunks.append(super_hunk)
else:
super_hunks = [[hunk] for hunk in hunks]
return [_SuperHunk(sh) for sh in super_hunks]
@@ -430,16 +430,16 @@

answers = ['y', 'n', 'q', 'a', 'd', 'g']
if next_pending is not None:
- answers += ['j']
+ answers.append('j')
if position < len(super_hunks) - 1:
- answers += ['J']
+ answers.append('J')
if prev_pending is not None:
- answers += ['k']
+ answers.append('k')
if position > 0:
- answers += ['K']
+ answers.append('K')
if len(super_hunk) > 1:
- answers += ['s']
- answers += ['?']
+ answers.append('s')
+ answers.append('?')

pywikibot.info(self._generate_diff(super_hunk))
choice = pywikibot.input('Accept this hunk [{}]?'.format(
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index 15f7e64..3f1da0b 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -485,7 +485,7 @@
assert not specific_entries, (
'generic entries defined after specific in "{}"'
.format(variants))
- plural_entries += [plural]
+ plural_entries.append(plural)

if num in specific_entries:
return specific_entries[num]
diff --git a/pywikibot/page/_category.py b/pywikibot/page/_category.py
index 56d5635..fb42b80 100644
--- a/pywikibot/page/_category.py
+++ b/pywikibot/page/_category.py
@@ -350,7 +350,7 @@
total -= len(cached)
if total <= 0:
break
- cache[page.oldest_revision.timestamp] += [page]
+ cache[page.oldest_revision.timestamp].append(page)
else:
# clear cache
assert total is None or total > 0, \
diff --git a/pywikibot/scripts/login.py b/pywikibot/scripts/login.py
index dc7d636..76fc653 100755
--- a/pywikibot/scripts/login.py
+++ b/pywikibot/scripts/login.py
@@ -149,7 +149,7 @@
elif arg == '-async':
asyncronous = True
else:
- unknown_args += [arg]
+ unknown_args.append(arg)

if pywikibot.bot.suggest_help(unknown_parameters=unknown_args):
return
diff --git a/pywikibot/site/_siteinfo.py b/pywikibot/site/_siteinfo.py
index 4eb1293..2863823 100644
--- a/pywikibot/site/_siteinfo.py
+++ b/pywikibot/site/_siteinfo.py
@@ -238,7 +238,7 @@
pywikibot.debug(
"Load siteinfo properties '{}' along with 'general'"
.format("', '".join(props)))
- props += ['general']
+ props.append('general')
default_info = self._get_siteinfo(props, expiry)
for prop in props:
self._cache[prop] = default_info[prop]
diff --git a/pywikibot/site/_upload.py b/pywikibot/site/_upload.py
index 1438554..7239ead 100644
--- a/pywikibot/site/_upload.py
+++ b/pywikibot/site/_upload.py
@@ -209,7 +209,7 @@
'using a file name.')
props = ['size']
if verify_stash:
- props += ['sha1']
+ props.append('sha1')
stash_info = self.site.stash_info(file_key, props)
if offset is True:
offset = stash_info['size']
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 72e60ca..a81abb1 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -1342,7 +1342,7 @@
site = insite.getSite(code=code)
if site in sites:
del sites[sites.index(site)]
- firstsites += [site]
+ firstsites.append(site)
sites = firstsites + sites
return sites

diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py
index 2142573..0f6ecfa 100644
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -210,7 +210,7 @@
text_parts = old_parts
else:
text_parts = new_parts
- text_parts += ['default']
+ text_parts.append('default')
# match.split() includes every regex group; for each matched color
# fg_col:b_col, fg_col and bg_col are added to the resulting list.
len_text_parts = len(text_parts[::4])
@@ -461,7 +461,7 @@
if not options:
raise ValueError('No options are given.')
if automatic_quit:
- options += [QuitKeyboardInterrupt()]
+ options.append(QuitKeyboardInterrupt())
if default:
default = default.lower()
for i, option in enumerate(options):
diff --git a/scripts/listpages.py b/scripts/listpages.py
index e4298d7..44e8d34 100755
--- a/scripts/listpages.py
+++ b/scripts/listpages.py
@@ -196,8 +196,8 @@
self.num += 1
if self.opt.tofile or not self.opt.notitle:
page_fmt = Formatter(page, self.opt.outputlang)
- self.output_list += [page_fmt.output(num=self.num,
- fmt=self.opt.format)]
+ self.output_list.append(
+ page_fmt.output(num=self.num, fmt=self.opt.format))
if self.opt['get']:
try:
pywikibot.stdout(page.text)
diff --git a/scripts/upload.py b/scripts/upload.py
index d37d448..d8bdc9a 100755
--- a/scripts/upload.py
+++ b/scripts/upload.py
@@ -190,10 +190,10 @@
additional = ''
missing = []
if url is None:
- missing += ['filename']
+ missing.append('filename')
additional = error + ' '
if description is None:
- missing += ['description']
+ missing.append('description')
if aborts is not True and ignorewarn is not True:
additional += ('Either -ignorewarn or -abortonwarn must be '
'defined for all codes. ')

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I29f521671b5b4da990d8579d95bf4f9127d2b4d9
Gerrit-Change-Number: 926734
Gerrit-PatchSet: 2
Gerrit-Owner: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged