Skip to content

Commit fc755da

Browse files
committed
Avoid having a local function seem to be a method
The kill_process local function defined in the Git.execute method is a local function and not a method, but it was easy to misread as a method for two reasons: - Its docstring described it as a method. - It was named with a leading underscore, as though it were a nonpublic method. But this name is a local variable, and local variables are always nonpublic (except when they are function parameters, in which case they are in a sense public). A leading underscore in a local variable name usually means the variable is unused in the function. This fixes the docstring and drops the leading underscore from the name. If this is ever extracted from the Git.execute method and placed at class or module scope, then the name can be changed back.
1 parent 133271b commit fc755da

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: git/cmd.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1012,8 +1012,8 @@ def execute(
10121012
if as_process:
10131013
return self.AutoInterrupt(proc, command)
10141014

1015-
def _kill_process(pid: int) -> None:
1016-
"""Callback method to kill a process."""
1015+
def kill_process(pid: int) -> None:
1016+
"""Callback to kill a process."""
10171017
p = Popen(
10181018
["ps", "--ppid", str(pid)],
10191019
stdout=PIPE,
@@ -1046,7 +1046,7 @@ def _kill_process(pid: int) -> None:
10461046

10471047
if kill_after_timeout is not None:
10481048
kill_check = threading.Event()
1049-
watchdog = threading.Timer(kill_after_timeout, _kill_process, args=(proc.pid,))
1049+
watchdog = threading.Timer(kill_after_timeout, kill_process, args=(proc.pid,))
10501050

10511051
# Wait for the process to return
10521052
status = 0

0 commit comments

Comments
 (0)