3939
4040# typing ------------------------------------------------------------------
4141
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
4343
44- from git .types import PathLike ,TypeGuard , Literal
44+ from git .types import PathLike ,Literal
4545
4646if TYPE_CHECKING :
4747from git .repo import Repo
@@ -323,16 +323,18 @@ def _iter_from_process_or_stream(cls, repo: 'Repo', proc_or_stream: Union[Popen,
323323 :param proc: git-rev-list process instance - one sha per line
324324 :return: iterator returning Commit objects"""
325325
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')
328328
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')
331331
332- if is_proc (proc_or_stream ):
332+ if hasattr (proc_or_stream ,'wait' ):
333+ proc_or_stream = cast (Popen ,proc_or_stream )
333334if proc_or_stream .stdout is not None :
334335stream = 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 )
336338stream = proc_or_stream
337339
338340readline = stream .readline
@@ -351,7 +353,8 @@ def is_stream(inp) -> TypeGuard[IO]:
351353# END for each line in stream
352354# TODO: Review this - it seems process handling got a bit out of control
353355# 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 )
355358finalize_process (proc_or_stream )
356359
357360@classmethod