36
36
37
37
# typing-------------------------------------------------------
38
38
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
40
40
41
41
from git .types import PathLike , Literal , TBD , TypeGuard
42
42
@@ -559,8 +559,8 @@ def delete_url(self, url: str, **kwargs: Any) -> 'Remote':
559
559
def urls (self ) -> Iterator [str ]:
560
560
""":return: Iterator yielding all configured URL targets on a remote as strings"""
561
561
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 )
564
564
for line in remote_details .split ('\n ' ):
565
565
yield line
566
566
except GitCommandError as ex :
@@ -571,14 +571,16 @@ def urls(self) -> Iterator[str]:
571
571
#
572
572
if 'Unknown subcommand: get-url' in str (ex ):
573
573
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 )
575
576
for line in remote_details .split ('\n ' ):
576
577
if ' Push URL:' in line :
577
578
yield line .split (': ' )[- 1 ]
578
579
except GitCommandError as _ex :
579
580
if any (msg in str (_ex ) for msg in ['correct access rights' , 'cannot run ssh' ]):
580
581
# 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 )
582
584
for line in remote_details .split ('\n ' ):
583
585
yield line
584
586
else :
0 commit comments