Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit144817a

Browse files
sroetByron
authored andcommitted
make flake8 and mypy happy
1 parentcd2d538 commit144817a

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

‎git/cmd.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,22 @@ def pump_stream(cmdline: List[str], name: str, stream: Union[BinaryIO, TextIO],
154154
fortinthreads:
155155
t.join(timeout=kill_after_timeout)
156156
ift.is_alive():
157-
ifhasattr(process,'proc'):# Assume it is aGit.AutoInterrupt:
157+
ifisinstance(process,Git.AutoInterrupt):
158158
process._terminate()
159159
else:# Don't want to deal with the other case
160-
raiseRuntimeError(f"Thread join() timed out in cmd.handle_process_output()."
161-
" kill_after_timeout={kill_after_timeout} seconds")
160+
raiseRuntimeError("Thread join() timed out in cmd.handle_process_output()."
161+
f" kill_after_timeout={kill_after_timeout} seconds")
162162
ifstderr_handler:
163-
stderr_handler("error: process killed because it timed out."
164-
f" kill_after_timeout={kill_after_timeout} seconds")
163+
error_str:Union[str,bytes]= (
164+
"error: process killed because it timed out."
165+
f" kill_after_timeout={kill_after_timeout} seconds")
166+
ifnotdecode_streamsandisinstance(p_stderr,BinaryIO):
167+
# Assume stderr_handler needs binary input
168+
error_str=cast(str,error_str)
169+
error_str=error_str.encode()
170+
# We ignore typing on the next line because mypy does not like
171+
# the way we infered that stderr takes str of bytes
172+
stderr_handler(error_str)# type: ignore
165173

166174
iffinalizer:
167175
returnfinalizer(process)
@@ -404,7 +412,7 @@ class AutoInterrupt(object):
404412
def__init__(self,proc:Union[None,subprocess.Popen],args:Any)->None:
405413
self.proc=proc
406414
self.args=args
407-
self.status=None
415+
self.status:Union[int,None]=None
408416

409417
def_terminate(self)->None:
410418
"""Terminate the underlying process"""
@@ -447,8 +455,6 @@ def _terminate(self) -> None:
447455
call(("TASKKILL /F /T /PID %s 2>nul 1>nul"%str(proc.pid)),shell=True)
448456
# END exception handling
449457

450-
451-
452458
def__del__(self)->None:
453459
self._terminate()
454460

@@ -465,11 +471,11 @@ def wait(self, stderr: Union[None, str, bytes] = b'') -> int:
465471
ifstderrisNone:
466472
stderr_b=b''
467473
stderr_b=force_bytes(data=stderr,encoding='utf-8')
468-
474+
status:Union[int,None]
469475
ifself.procisnotNone:
470476
status=self.proc.wait()
471477
p_stderr=self.proc.stderr
472-
else:#Assume the underlying proc was killed earlier or never existed
478+
else:#Assume the underlying proc was killed earlier or never existed
473479
status=self.status
474480
p_stderr=None
475481

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp