summaryrefslogtreecommitdiff
path: root/git/remote.py
diff options
context:
space:
mode:
authorYobmod <yobmod@gmail.com>2021-06-25 20:52:29 +0100
committerYobmod <yobmod@gmail.com>2021-06-25 20:52:29 +0100
commit7b09003fffa8196277bcfaa9984a3e6833805a6d (patch)
tree6d5a58d9e98ee43e11ab71534e3bc9062f01e242 /git/remote.py
parentdc8d23d3d6e735d70fd0a60641c58f6e44e17029 (diff)
downloadgitpython-7b09003fffa8196277bcfaa9984a3e6833805a6d.tar.gz
replace cast()s with asserts in remote.py
Diffstat (limited to 'git/remote.py')
-rw-r--r--git/remote.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/git/remote.py b/git/remote.py
index e6daffe0..a6232db3 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -36,7 +36,7 @@ from .refs import (
# typing-------------------------------------------------------
-from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, TYPE_CHECKING, Union, cast, overload
+from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, TYPE_CHECKING, Union, overload
from git.types import PathLike, Literal, TBD, TypeGuard
@@ -559,8 +559,8 @@ class Remote(LazyMixin, IterableObj):
def urls(self) -> Iterator[str]:
""":return: Iterator yielding all configured URL targets on a remote as strings"""
try:
- # can replace cast with type assert?
- remote_details = cast(str, self.repo.git.remote("get-url", "--all", self.name))
+ remote_details = self.repo.git.remote("get-url", "--all", self.name)
+ assert isinstance(remote_details, str)
for line in remote_details.split('\n'):
yield line
except GitCommandError as ex:
@@ -571,14 +571,16 @@ class Remote(LazyMixin, IterableObj):
#
if 'Unknown subcommand: get-url' in str(ex):
try:
- remote_details = cast(str, self.repo.git.remote("show", self.name))
+ remote_details = self.repo.git.remote("show", self.name)
+ assert isinstance(remote_details, str)
for line in remote_details.split('\n'):
if ' Push URL:' in line:
yield line.split(': ')[-1]
except GitCommandError as _ex:
if any(msg in str(_ex) for msg in ['correct access rights', 'cannot run ssh']):
# If ssh is not setup to access this repository, see issue 694
- remote_details = cast(str, self.repo.git.config('--get-all', 'remote.%s.url' % self.name))
+ remote_details = self.repo.git.config('--get-all', 'remote.%s.url' % self.name)
+ assert isinstance(remote_details, str)
for line in remote_details.split('\n'):
yield line
else: