39
39
40
40
# typing ------------------------------------------------------------------
41
41
42
- from typing import Any , IO , Iterator , List , Sequence , Tuple , Union , TYPE_CHECKING
42
+ from typing import Any , IO , Iterator , List , Sequence , Tuple , Union , TYPE_CHECKING , cast
43
43
44
- from git .types import PathLike , TypeGuard , Literal
44
+ from git .types import PathLike , Literal
45
45
46
46
if TYPE_CHECKING :
47
47
from git .repo import Repo
@@ -323,16 +323,18 @@ def _iter_from_process_or_stream(cls, repo: 'Repo', proc_or_stream: Union[Popen,
323
323
:param proc: git-rev-list process instance - one sha per line
324
324
:return: iterator returning Commit objects"""
325
325
326
- def is_proc (inp ) -> TypeGuard [Popen ]:
327
- return hasattr (proc_or_stream , 'wait' ) and not hasattr (proc_or_stream , 'readline' )
326
+ # def is_proc(inp) -> TypeGuard[Popen]:
327
+ # return hasattr(proc_or_stream, 'wait') and not hasattr(proc_or_stream, 'readline')
328
328
329
- def is_stream (inp ) -> TypeGuard [IO ]:
330
- return hasattr (proc_or_stream , 'readline' )
329
+ # def is_stream(inp) -> TypeGuard[IO]:
330
+ # return hasattr(proc_or_stream, 'readline')
331
331
332
- if is_proc (proc_or_stream ):
332
+ if hasattr (proc_or_stream , 'wait' ):
333
+ proc_or_stream = cast (Popen , proc_or_stream )
333
334
if proc_or_stream .stdout is not None :
334
335
stream = proc_or_stream .stdout
335
- elif is_stream (proc_or_stream ):
336
+ elif hasattr (proc_or_stream , 'readline' ):
337
+ proc_or_stream = cast (IO , proc_or_stream )
336
338
stream = proc_or_stream
337
339
338
340
readline = stream .readline
@@ -351,7 +353,8 @@ def is_stream(inp) -> TypeGuard[IO]:
351
353
# END for each line in stream
352
354
# TODO: Review this - it seems process handling got a bit out of control
353
355
# due to many developers trying to fix the open file handles issue
354
- if is_proc (proc_or_stream ):
356
+ if hasattr (proc_or_stream , 'wait' ):
357
+ proc_or_stream = cast (Popen , proc_or_stream )
355
358
finalize_process (proc_or_stream )
356
359
357
360
@ classmethod
0 commit comments