Skip to content

remove duplicate imports #1579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import logging
import os
import signal
from subprocess import call, Popen, PIPE, DEVNULL
import subprocess
import threading
from textwrap import dedent
Expand Down Expand Up @@ -91,7 +90,7 @@


def handle_process_output(
process: "Git.AutoInterrupt" | Popen,
process: "Git.AutoInterrupt" | subprocess.Popen,
stdout_handler: Union[
None,
Callable[[AnyStr], None],
Expand Down Expand Up @@ -154,7 +153,7 @@ def pump_stream(
p_stdout = process.proc.stdout if process.proc else None
p_stderr = process.proc.stderr if process.proc else None
else:
process = cast(Popen, process)
process = cast(subprocess.Popen, process)
cmdline = getattr(process, "args", "")
p_stdout = process.stdout
p_stderr = process.stderr
Expand Down Expand Up @@ -557,7 +556,7 @@ def _terminate(self) -> None:
# we simply use the shell and redirect to nul. Its slower than CreateProcess, question
# is whether we really want to see all these messages. Its annoying no matter what.
if is_win:
call(
subprocess.call(
("TASKKILL /F /T /PID %s 2>nul 1>nul" % str(proc.pid)),
shell=True,
)
Expand Down Expand Up @@ -969,7 +968,7 @@ def execute(
cmd_not_found_exception = FileNotFoundError # NOQA # exists, flake8 unknown @UndefinedVariable
# end handle

stdout_sink = PIPE if with_stdout else getattr(subprocess, "DEVNULL", None) or open(os.devnull, "wb")
stdout_sink = subprocess.PIPE if with_stdout else getattr(subprocess, "DEVNULL", None) or open(os.devnull, "wb")
istream_ok = "None"
if istream:
istream_ok = "<valid stream>"
Expand All @@ -982,13 +981,13 @@ def execute(
istream_ok,
)
try:
proc = Popen(
proc = subprocess.Popen(
command,
env=env,
cwd=cwd,
bufsize=-1,
stdin=istream or DEVNULL,
stderr=PIPE,
stdin=istream or subprocess.DEVNULL,
stderr=subprocess.PIPE,
stdout=stdout_sink,
shell=shell is not None and shell or self.USE_SHELL,
close_fds=is_posix, # unsupported on windows
Expand All @@ -1009,9 +1008,9 @@ def execute(

def _kill_process(pid: int) -> None:
"""Callback method to kill a process."""
p = Popen(
p = subprocess.Popen(
["ps", "--ppid", str(pid)],
stdout=PIPE,
stdout=subprocess.PIPE,
creationflags=PROC_CREATIONFLAGS,
)
child_pids = []
Expand Down Expand Up @@ -1355,7 +1354,7 @@ def _get_persistent_cmd(self, attr_name: str, cmd_name: str, *args: Any, **kwarg
if cur_val is not None:
return cur_val

options = {"istream": PIPE, "as_process": True}
options = {"istream": subprocess.PIPE, "as_process": True}
options.update(kwargs)

cmd = self._call_process(cmd_name, *args, **options)
Expand Down