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

Commitf1ace25

Browse files
committed
Add types to cmd.py AutoInterrupt
1 parent887f249 commitf1ace25

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

‎git/cmd.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,11 @@ class AutoInterrupt(object):
357357

358358
__slots__= ("proc","args")
359359

360-
def__init__(self,proc,args):
360+
def__init__(self,proc:Union[None,subprocess.Popen],args:Any)->None:
361361
self.proc=proc
362362
self.args=args
363363

364-
def__del__(self):
364+
def__del__(self)->None:
365365
ifself.procisNone:
366366
return
367367

@@ -377,13 +377,13 @@ def __del__(self):
377377
# did the process finish already so we have a return code ?
378378
try:
379379
ifproc.poll()isnotNone:
380-
return
380+
returnNone
381381
exceptOSErrorasex:
382382
log.info("Ignored error after process had died: %r",ex)
383383

384384
# can be that nothing really exists anymore ...
385385
ifosisNoneorgetattr(os,'kill',None)isNone:
386-
return
386+
returnNone
387387

388388
# try to kill it
389389
try:
@@ -400,10 +400,11 @@ def __del__(self):
400400
call(("TASKKILL /F /T /PID %s 2>nul 1>nul"%str(proc.pid)),shell=True)
401401
# END exception handling
402402

403-
def__getattr__(self,attr):
403+
def__getattr__(self,attr:str)->Any:
404404
returngetattr(self.proc,attr)
405405

406-
defwait(self,stderr=b''):# TODO: Bad choice to mimic `proc.wait()` but with different args.
406+
# TODO: Bad choice to mimic `proc.wait()` but with different args.
407+
defwait(self,stderr:Union[None,bytes]=b'')->int:
407408
"""Wait for the process and return its status code.
408409
409410
:param stderr: Previously read value of stderr, in case stderr is already closed.
@@ -413,20 +414,22 @@ def wait(self, stderr=b''): # TODO: Bad choice to mimic `proc.wait()` but with
413414
stderr=b''
414415
stderr=force_bytes(data=stderr,encoding='utf-8')
415416

416-
status=self.proc.wait()
417-
418-
defread_all_from_possibly_closed_stream(stream):
419-
try:
420-
returnstderr+force_bytes(stream.read())
421-
exceptValueError:
422-
returnstderrorb''
417+
ifself.procisnotNone:
418+
status=self.proc.wait()
423419

424-
ifstatus!=0:
425-
errstr=read_all_from_possibly_closed_stream(self.proc.stderr)
426-
log.debug('AutoInterrupt wait stderr: %r'% (errstr,))
427-
raiseGitCommandError(remove_password_if_present(self.args),status,errstr)
420+
defread_all_from_possibly_closed_stream(stream):
421+
try:
422+
returnstderr+force_bytes(stream.read())
423+
exceptValueError:
424+
returnstderrorb''
425+
426+
ifstatus!=0:
427+
errstr=read_all_from_possibly_closed_stream(self.proc.stderr)
428+
log.debug('AutoInterrupt wait stderr: %r'% (errstr,))
429+
raiseGitCommandError(remove_password_if_present(self.args),status,errstr)
428430
# END status handling
429431
returnstatus
432+
430433
# END auto interrupt
431434

432435
classCatFileContentStream(object):

‎git/exc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class GitCommandError(CommandError):
9191
""" Thrown if execution of the git command fails with non-zero status code. """
9292

9393
def__init__(self,command:Union[List[str],Tuple[str, ...],str],
94-
status:Union[str,None,Exception]=None,
94+
status:Union[str,int,None,Exception]=None,
9595
stderr:Optional[IO[str]]=None,
9696
stdout:Optional[IO[str]]=None,
9797
)->None:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp