summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git/refs/log.py12
-rw-r--r--git/remote.py12
2 files changed, 13 insertions, 11 deletions
diff --git a/git/refs/log.py b/git/refs/log.py
index 363c3c5d..f850ba24 100644
--- a/git/refs/log.py
+++ b/git/refs/log.py
@@ -82,23 +82,23 @@ class RefLogEntry(tuple):
return RefLogEntry((oldhexsha, newhexsha, actor, (time, tz_offset), message))
@classmethod
- def from_line(cls, line):
+ def from_line(cls, line: bytes) -> 'RefLogEntry':
""":return: New RefLogEntry instance from the given revlog line.
:param line: line bytes without trailing newline
:raise ValueError: If line could not be parsed"""
- line = line.decode(defenc)
- fields = line.split('\t', 1)
+ line_str = line.decode(defenc)
+ fields = line_str.split('\t', 1)
if len(fields) == 1:
info, msg = fields[0], None
elif len(fields) == 2:
info, msg = fields
else:
raise ValueError("Line must have up to two TAB-separated fields."
- " Got %s" % repr(line))
+ " Got %s" % repr(line_str))
# END handle first split
- oldhexsha = info[:40] # type: str
- newhexsha = info[41:81] # type: str
+ oldhexsha = info[:40]
+ newhexsha = info[41:81]
for hexsha in (oldhexsha, newhexsha):
if not cls._re_hexsha_only.match(hexsha):
raise ValueError("Invalid hexsha: %r" % (hexsha,))
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: