5959#{ Utilities
6060
6161
62- def add_progress (kwargs : Any , git : Git , progress : Optional [Callable [..., Any ]]) -> Any :
62+ def add_progress (kwargs : Any , git : Git , progress : Union [Callable [..., Any ], None ]) -> Any :
6363 """Add the --progress flag to the given kwargs dict if supported by the
6464 git command. If the actual progress in the given progress instance is not
6565 given, we do not request any progress
@@ -741,15 +741,15 @@ def _get_fetch_info_from_stderr(self, proc: TBD,
741741 return output
742742
743743 def _get_push_info (self , proc : TBD ,
744- progress : Union [Callable [..., Any ], RemoteProgress , None ]) -> List [ PushInfo ] :
744+ progress : Union [Callable [..., Any ], RemoteProgress , None ]) -> IterableList :
745745 progress = to_progress_instance (progress )
746746
747747 # read progress information from stderr
748748 # we hope stdout can hold all the data, it should ...
749749 # read the lines manually as it will use carriage returns between the messages
750750 # to override the previous one. This is why we read the bytes manually
751751 progress_handler = progress .new_message_handler ()
752- output = []
752+ output = IterableList ( 'push_infos' )
753753
754754 def stdout_handler (line : str ) -> None :
755755 try :
@@ -783,7 +783,9 @@ def _assert_refspec(self) -> None:
783783 finally :
784784 config .release ()
785785
786- def fetch (self , refspec = None , progress = None , verbose = True , ** kwargs ):
786+ def fetch (self , refspec : Union [str , List [str ], None ] = None ,
787+ progress : Union [Callable [..., Any ], None ] = None ,
788+ verbose : bool = True , ** kwargs : Any ) -> IterableList :
787789 """Fetch the latest changes for this remote
788790
789791 :param refspec:
@@ -814,10 +816,12 @@ def fetch(self, refspec=None, progress=None, verbose=True, **kwargs):
814816 if refspec is None :
815817 # No argument refspec, then ensure the repo's config has a fetch refspec.
816818 self ._assert_refspec ()
819+ assert refspec is not None # for typing
817820 kwargs = add_progress (kwargs , self .repo .git , progress )
818821 if isinstance (refspec , list ):
819822 args = refspec
820823 else :
824+
821825 args = [refspec ]
822826
823827 proc = self .repo .git .fetch (self , * args , as_process = True , with_stdout = False ,
@@ -827,7 +831,9 @@ def fetch(self, refspec=None, progress=None, verbose=True, **kwargs):
827831 self .repo .odb .update_cache ()
828832 return res
829833
830- def pull (self , refspec = None , progress = None , ** kwargs ):
834+ def pull (self , refspec : Union [str , List [str ], None ] = None ,
835+ progress : Union [Callable [..., Any ], None ] = None ,
836+ ** kwargs : Any ) -> IterableList :
831837 """Pull changes from the given branch, being the same as a fetch followed
832838 by a merge of branch with your local branch.
833839
@@ -846,7 +852,9 @@ def pull(self, refspec=None, progress=None, **kwargs):
846852 self .repo .odb .update_cache ()
847853 return res
848854
849- def push (self , refspec = None , progress = None , ** kwargs ):
855+ def push (self , refspec : Union [str , List [str ], None ] = None ,
856+ progress : Union [Callable [..., Any ], None ] = None ,
857+ ** kwargs : Any ) -> IterableList :
850858 """Push changes from source branch in refspec to target branch in refspec.
851859
852860 :param refspec: see 'fetch' method
0 commit comments