3636
3737# typing-------------------------------------------------------
3838
39- from typing import Any , Callable , Dict , Iterator , List , Optional , Sequence , TYPE_CHECKING , Union , cast , overload
39+ from typing import Any , Callable , Dict , Iterator , List , Optional , Sequence , TYPE_CHECKING , Union , overload
4040
4141from git .types import PathLike , Literal , TBD , TypeGuard
4242
@@ -559,8 +559,8 @@ def delete_url(self, url: str, **kwargs: Any) -> 'Remote':
559559 def urls (self ) -> Iterator [str ]:
560560 """:return: Iterator yielding all configured URL targets on a remote as strings"""
561561 try :
562- # can replace cast with type assert?
563- remote_details = cast ( str , self . repo . git . remote ( "get-url" , "--all" , self . name ) )
562+ remote_details = self . repo . git . remote ( "get-url" , "--all" , self . name )
563+ assert isinstance ( remote_details , str )
564564 for line in remote_details .split ('\n ' ):
565565 yield line
566566 except GitCommandError as ex :
@@ -571,14 +571,16 @@ def urls(self) -> Iterator[str]:
571571 #
572572 if 'Unknown subcommand: get-url' in str (ex ):
573573 try :
574- remote_details = cast (str , self .repo .git .remote ("show" , self .name ))
574+ remote_details = self .repo .git .remote ("show" , self .name )
575+ assert isinstance (remote_details , str )
575576 for line in remote_details .split ('\n ' ):
576577 if ' Push URL:' in line :
577578 yield line .split (': ' )[- 1 ]
578579 except GitCommandError as _ex :
579580 if any (msg in str (_ex ) for msg in ['correct access rights' , 'cannot run ssh' ]):
580581 # If ssh is not setup to access this repository, see issue 694
581- remote_details = cast (str , self .repo .git .config ('--get-all' , 'remote.%s.url' % self .name ))
582+ remote_details = self .repo .git .config ('--get-all' , 'remote.%s.url' % self .name )
583+ assert isinstance (remote_details , str )
582584 for line in remote_details .split ('\n ' ):
583585 yield line
584586 else :
0 commit comments