From 7057b9b81d69a734217b2ee3d6f817c12e3d880a Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Mon, 25 Dec 2023 09:09:25 -0500 Subject: [PATCH] In handle_process_output don't forward finalizer result The git.cmd.handle_process_output function is non-public (git.cmd.__all__ only lists Git) but used throughout GitPython and referenced in the git.util.RemoteProgress.new_message_handler docstring. Its finalizer argument is annotated to accept an optional callable that always returns None. It is always used this way in GitPython and RemoteProcess.new_message_handler is annotated accordingly. However, the handle_process_output docstring and implementation had documented the return value as the result of the finalizer, and the implementation had forwarded that result if passed. This modifies the docstring and implementation to disregard any result, in accordance with the everywhere-annotated assumption that the finalizer is conceptually void and the absence of any code in GitPython that uses the result of calling handle_process_output. None is now implicitly returned, simplifying the implementation and bringing it and the docstring in line with annotationd and usage. This would be a breaking change if done on a public function, but because handle_process_output is nonpublic (and documentation for it is omitted by Sphinx, so users probably don't wrongly think it is public), I believe this is safe and non-breaking. --- git/cmd.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/git/cmd.py b/git/cmd.py index 7297e4ae6..532086bc3 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -111,7 +111,6 @@ def handle_process_output( This function returns once the finalizer returns. - :return: Result of finalizer :param process: :class:`subprocess.Popen` instance :param stdout_handler: f(stdout_line_string), or None :param stderr_handler: f(stderr_line_string), or None @@ -205,9 +204,7 @@ def pump_stream( stderr_handler(error_str) # type: ignore if finalizer: - return finalizer(process) - else: - return None + finalizer(process) def dashify(string: str) -> str: