git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 16/21] git-p4: ensure there is a single space around all operators

From
Joel Holdsworth <jholdsworth@nvidia.com>
Date
Jan 16, 2022, 16:05 UTC
Message-ID
<20220116160550.514637-17-jholdsworth@nvidia.com>
In-Reply-To
<20220116160550.514637-1-jholdsworth@nvidia.com>

PEP8 requires that binary operators such as assignment and comparison operators should always be surrounded by a pair of single spaces, and recommends that all other binary operators should typically be surround by single spaces.

The recommendation is given here in the "Other Recommendations" section

https://www.python.org/dev/peps/pep-0008/#other-recommendations
Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
---
 git-p4.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index a014bdc7a5..b5cda50af0 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -67,7 +67,7 @@
 defaultLabelRegexp = r'[a-zA-Z0-9_\-.]+$'
 
 # The block size is reduced automatically if required
-defaultBlockSize = 1<<20
+defaultBlockSize = 1 << 20
 
 p4_access_checked = False
 
@@ -201,7 +201,7 @@ def prompt(prompt_text):
         sys.stderr.flush()
         sys.stdout.write(prompt_text)
         sys.stdout.flush()
-        response=sys.stdin.readline().strip().lower()
+        response = sys.stdin.readline().strip().lower()
         if not response:
             continue
         response = response[0]
@@ -256,7 +256,7 @@ def run_git_hook(cmd, param=[]):
         hooks_path = os.path.join(os.environ["GIT_DIR"], "hooks")
 
     if not isinstance(param, list):
-        param=[param]
+        param = [param]
 
     # resolve hook file name, OS depdenent
     hook_file = os.path.join(hooks_path, cmd)
@@ -2397,7 +2397,7 @@ def exportGitTags(self, gitTags):
             # Create the label - use the same view as the client spec we are using
             clientSpec = getClientSpec()
 
-            labelTemplate  = "Label: %s\n" % name
+            labelTemplate = "Label: %s\n" % name
             labelTemplate += "Description:\n"
             for b in body:
                 labelTemplate += "\t" + b + "\n"
@@ -2900,7 +2900,7 @@ def extractFilesFromCommit(self, commit, shelved=False, shelved_cl=0):
         files = []
         fnum = 0
         while "depotFile%s" % fnum in commit:
-            path =  commit["depotFile%s" % fnum]
+            path = commit["depotFile%s" % fnum]
             found = self.isPathWanted(decode_path(path))
             if not found:
                 fnum = fnum + 1
@@ -3983,7 +3983,7 @@ def run(self, args):
 
             p4Change = 0
             for branch in self.p4BranchesInGit:
-                logMsg =  extractLogMessageFromGitCommit(self.refPrefix + branch)
+                logMsg = extractLogMessageFromGitCommit(self.refPrefix + branch)
 
                 settings = extractSettingsGitLog(logMsg)
 
-- 
2.34.1
Previous: Joel HoldsworthNext: Joel Holdsworth
Message 18 of 29 in “git-p4: Various code tidy-ups”
  1. 00/21 git-p4: Various code tidy-upsJoel Holdsworth, Jan 16, 2022
  2. 02/21 git-p4: remove unneeded semicolons from statementsJoel Holdsworth, Jan 16, 2022
  3. Junio C HamanoJan 17, 2022
  4. 01/21 git-p4: add blank lines between functions and class definitionsJoel Holdsworth, Jan 16, 2022
  5. 03/21 git-p4: indent with 4-spacesJoel Holdsworth, Jan 16, 2022
  6. 04/21 git-p4: improve consistency of docstring formattingJoel Holdsworth, Jan 16, 2022
  7. 05/21 git-p4: convert descriptive class and function comments into docstringsJoel Holdsworth, Jan 16, 2022
  8. 06/21 git-p4: remove commented codeJoel Holdsworth, Jan 16, 2022
  9. 07/21 git-p4: sort and de-duplcate pylint disable listJoel Holdsworth, Jan 16, 2022
  10. 08/21 git-p4: remove padding from lists, tuples and function argumentsJoel Holdsworth, Jan 16, 2022
  11. 09/21 git-p4: remove spaces around default argumentsJoel Holdsworth, Jan 16, 2022
  12. 10/21 git-p4: removed brackets when assigning multiple return valuesJoel Holdsworth, Jan 16, 2022
  13. 11/21 git-p4: place a single space after every commaJoel Holdsworth, Jan 16, 2022
  14. 12/21 git-p4: remove extraneous spaces before function argumentsJoel Holdsworth, Jan 16, 2022
  15. 13/21 git-p4: remove redundant backslash-continuations inside bracketsJoel Holdsworth, Jan 16, 2022
  16. 14/21 git-p4: remove spaces between dictionary keys and colonsJoel Holdsworth, Jan 16, 2022
  17. 15/21 git-p4: ensure every comment has a single #Joel Holdsworth, Jan 16, 2022
  18. 16/21 git-p4: ensure there is a single space around all operatorsJoel Holdsworth, Jan 16, 2022
  19. 17/21 git-p4: normalize indentation of lines in conditionalsJoel Holdsworth, Jan 16, 2022
  20. 18/21 git-p4: compare to singletons with "is" and "is not"Joel Holdsworth, Jan 16, 2022
  21. 20/21 git-p4: move inline comments to line aboveJoel Holdsworth, Jan 16, 2022
  22. 21/21 git-p4: seperate multiple statements onto seperate linesJoel Holdsworth, Jan 16, 2022
  23. 19/21 git-p4: only seperate code blocks by a single empty lineJoel Holdsworth, Jan 16, 2022
  24. Junio C HamanoJan 17, 2022
  25. Joel HoldsworthFeb 3, 2022
  26. Junio C HamanoFeb 3, 2022
  27. Joel HoldsworthFeb 4, 2022
  28. Junio C HamanoFeb 4, 2022
  29. Junio C HamanoJan 17, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.