git-p4: removed brackets when assigning multiple return values
In several places, git-p4 contains code of the form: (a, b) = foo() In each case, multiple values are returned through a tuple or a list and bound into multiple values. The brackets around the assigned variables are redundant and can be removed: a, b = foo() Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Joel Holdsworth committed
Apr 1, 2022 at 15:24 UTC
0874bb016a06703d942092c23922c1e4e2bf5f4a
1 file changed
+19
-19
git-p4.py
+19
-19
@@ -285,7 +285,7 @@ def read_pipe_full(c, *k, **kw):
285
286
p = subprocess.Popen(
287
c, stdout=subprocess.PIPE, stderr=subprocess.PIPE, *k, **kw)
288
- (out, err) = p.communicate()
288
+ out, err = p.communicate()
289
return (p.returncode, out, decode_text_stream(err))
290
291
@@ -296,7 +296,7 @@ def read_pipe(c, ignore_error=False, raw=False, *k, **kw):
296
297
If raw is True, do not attempt to decode output text.
298
"""
299
- (retcode, out, err) = read_pipe_full(c, *k, **kw)
299
+ retcode, out, err = read_pipe_full(c, *k, **kw)
300
if retcode != 0:
301
if ignore_error:
302
out = ""
@@ -311,7 +311,7 @@ def read_pipe_text(c, *k, **kw):
311
"""Read output from a command with trailing whitespace stripped. On error,
312
returns None.
313
"""
314
- (retcode, out, err) = read_pipe_full(c, *k, **kw)
314
+ retcode, out, err = read_pipe_full(c, *k, **kw)
315
if retcode != 0:
316
return None
317
else:
@@ -365,7 +365,7 @@ def p4_has_move_command():
365
return False
366
cmd = p4_build_cmd(["move", "-k", "@from", "@to"])
367
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
368
- (out, err) = p.communicate()
368
+ out, err = p.communicate()
369
err = decode_text_stream(err)
370
# return code will be 1 in either case
371
if err.find("Invalid option") >= 0:
@@ -606,7 +606,7 @@ def p4_keywords_regexp_for_file(file):
606
if not os.path.exists(file):
607
return None
608
else:
609
- (type_base, type_mods) = split_p4_type(p4_type(file))
609
+ type_base, type_mods = split_p4_type(p4_type(file))
610
return p4_keywords_regexp_for_type(type_base, type_mods)
611
612
@@ -1154,7 +1154,7 @@ def p4ChangesForPaths(depotPaths, changeRange, requestedBlockSize):
1154
parts = changeRange.split(',')
1155
assert len(parts) == 2
1156
try:
1157
- (changeStart, changeEnd) = p4ParseNumericChangeRange(parts)
1157
+ changeStart, changeEnd = p4ParseNumericChangeRange(parts)
1158
block_size = chooseBlockSize(requestedBlockSize)
1159
except ValueError:
1160
changeStart = parts[0][1:]
@@ -1379,7 +1379,7 @@ class LargeFileSystem(object):
1379
"""
1380
if self.exceedsLargeFileThreshold(relPath, contents) or self.hasLargeFileExtension(relPath):
1381
contentTempFile = self.generateTempFile(contents)
1382
- (pointer_git_mode, contents, localLargeFile) = self.generatePointer(contentTempFile)
1382
+ pointer_git_mode, contents, localLargeFile = self.generatePointer(contentTempFile)
1383
if pointer_git_mode:
1384
git_mode = pointer_git_mode
1385
if localLargeFile:
@@ -1750,7 +1750,7 @@ class P4Submit(Command, P4UserMap):
1750
"""Attempt to zap the RCS keywords in a p4 controlled file matching the
1751
given regex.
1752
"""
1753
- (handle, outFileName) = tempfile.mkstemp(dir='.')
1753
+ handle, outFileName = tempfile.mkstemp(dir='.')
1754
try:
1755
with os.fdopen(handle, "wb") as outFile, open(file, "rb") as inFile:
1756
for line in inFile.readlines():
@@ -1782,7 +1782,7 @@ class P4Submit(Command, P4UserMap):
1782
def checkValidP4Users(self,commits):
1783
"""Check if any git authors cannot be mapped to p4 users."""
1784
for id in commits:
1785
- (user,email) = self.p4UserForCommit(id)
1785
+ user, email = self.p4UserForCommit(id)
1786
if not user:
1787
msg = "Cannot find p4 user for email %s in commit %s." % (email, id)
1788
if gitConfigBool("git-p4.allowMissingP4Users"):
@@ -1857,7 +1857,7 @@ class P4Submit(Command, P4UserMap):
1857
outside the depot path we're committing into.
1858
"""
1859
1860
- [upstream, settings] = findUpstreamBranchPoint()
1860
+ upstream, settings = findUpstreamBranchPoint()
1861
1862
template = """\
1863
# A Perforce Change Specification.
@@ -1991,7 +1991,7 @@ class P4Submit(Command, P4UserMap):
1991
print("Applying", read_pipe(["git", "show", "-s",
1992
"--format=format:%h %s", id]))
1993
1994
- (p4User, gitEmail) = self.p4UserForCommit(id)
1994
+ p4User, gitEmail = self.p4UserForCommit(id)
1995
1996
diff = read_pipe_lines(
1997
["git", "diff-tree", "-r"] + self.diffOpts + ["{}^".format(id), id])
@@ -2156,7 +2156,7 @@ class P4Submit(Command, P4UserMap):
2156
#
2157
logMessage = extractLogMessageFromGitCommit(id)
2158
logMessage = logMessage.strip()
2159
- (logMessage, jobs) = self.separate_jobs_from_description(logMessage)
2159
+ logMessage, jobs = self.separate_jobs_from_description(logMessage)
2160
2161
template = self.prepareSubmitTemplate(update_shelve)
2162
submitTemplate = self.prepareLogMessage(template, logMessage, jobs)
@@ -2174,7 +2174,7 @@ class P4Submit(Command, P4UserMap):
2174
submitTemplate += separatorLine
2175
submitTemplate += self.get_diff_description(editedFiles, filesToAdd, symlinks)
2176
2177
- (handle, fileName) = tempfile.mkstemp()
2177
+ handle, fileName = tempfile.mkstemp()
2178
tmpFile = os.fdopen(handle, "w+b")
2179
if self.isWindows:
2180
submitTemplate = submitTemplate.replace("\n", "\r\n")
@@ -2381,7 +2381,7 @@ class P4Submit(Command, P4UserMap):
2381
if len(allowSubmit) > 0 and not self.master in allowSubmit.split(","):
2382
die("%s is not in git-p4.allowSubmit" % self.master)
2383
2384
- [upstream, settings] = findUpstreamBranchPoint()
2384
+ upstream, settings = findUpstreamBranchPoint()
2385
self.depotPath = settings['depot-paths'][0]
2386
if len(self.origin) == 0:
2387
self.origin = upstream
@@ -2981,7 +2981,7 @@ class P4Sync(Command, P4UserMap):
2981
file_path, relPath, format_size_human_readable(size)))
2982
sys.stdout.flush()
2983
2984
- (type_base, type_mods) = split_p4_type(file["type"])
2984
+ type_base, type_mods = split_p4_type(file["type"])
2985
2986
git_mode = "100644"
2987
if "x" in type_mods:
@@ -3046,7 +3046,7 @@ class P4Sync(Command, P4UserMap):
3046
contents = [regexp.sub(br'$\1$', c) for c in contents]
3047
3048
if self.largeFileSystem:
3049
- (git_mode, contents) = self.largeFileSystem.processContent(git_mode, relPath, contents)
3049
+ git_mode, contents = self.largeFileSystem.processContent(git_mode, relPath, contents)
3050
3051
self.writeToGitStream(git_mode, relPath, contents)
3052
@@ -3514,7 +3514,7 @@ class P4Sync(Command, P4UserMap):
3514
configBranches = gitConfigList("git-p4.branchList")
3515
for branch in configBranches:
3516
if branch:
3517
- (source, destination) = branch.split(":")
3517
+ source, destination = branch.split(":")
3518
self.knownBranches[destination] = source
3519
3520
lostAndFoundBranches.discard(destination)
@@ -4122,7 +4122,7 @@ class P4Rebase(Command):
4122
if len(read_pipe(["git", "diff-index", "HEAD", "--"])) > 0:
4123
die("You have uncommitted changes. Please commit them before rebasing or stash them away with git stash.")
4124
4125
- [upstream, settings] = findUpstreamBranchPoint()
4125
+ upstream, settings = findUpstreamBranchPoint()
4126
if len(upstream) == 0:
4127
die("Cannot find upstream branchpoint for rebase")
4128
@@ -4419,7 +4419,7 @@ def main():
4419
formatter=HelpFormatter())
4420
4421
try:
4422
- (cmd, args) = parser.parse_args(sys.argv[2:], cmd)
4422
+ cmd, args = parser.parse_args(sys.argv[2:], cmd)
4423
except:
4424
parser.print_help()
4425
raise