Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5b6fe83
Update typing-extensions version in requirements.txt
Yobmod Jun 23, 2021
00b5802
Merge branch 'gitpython-developers:main' into main
Yobmod Jun 23, 2021
6500844
Merge branch 'gitpython-developers:main' into main
Yobmod Jun 24, 2021
42e4f5e
Add types to tree.Tree
Yobmod Jun 24, 2021
c3903d8
Make IterableList generic and update throughout
Yobmod Jun 24, 2021
3cef949
Rename Iterable due to typing.Iterable. Add deprecation warning
Yobmod Jun 24, 2021
ae9d56e
Make Iterable deprecation warning on subclassing
Yobmod Jun 24, 2021
8bf00a6
fix an import
Yobmod Jun 24, 2021
26dfeb6
fix indent
Yobmod Jun 24, 2021
4f5d2fd
update docstring
Yobmod Jun 24, 2021
d9f9027
update some TBDs to configparser
Yobmod Jun 24, 2021
affee35
Add typedDict
Yobmod Jun 24, 2021
fe594eb
Add T_Tre_cache TypeVar
Yobmod Jun 24, 2021
59c8944
forward ref Gitconfigparser
Yobmod Jun 24, 2021
b72118e
Import TypeGuard to replace casts
Yobmod Jun 24, 2021
fb3fec3
Update typing-extensions dependancy to <py3.10 for typeguard
Yobmod Jun 24, 2021
a2d9011
Add asserts and casts for T_Tree_cache
Yobmod Jun 24, 2021
0eae33d
Add is_flatLiteral() Typeguard[] to remote.py
Yobmod Jun 25, 2021
5b0465c
fix assert
Yobmod Jun 25, 2021
dc8d23d
Add '?' to controlcharacter literal
Yobmod Jun 25, 2021
7b09003
replace cast()s with asserts in remote.py
Yobmod Jun 25, 2021
aba4d9b
replace cast()s with asserts in fun.py
Yobmod Jun 25, 2021
07bfe1a
trigger checks to rurun
Yobmod Jun 25, 2021
09fb227
Add type to submodule to trigger checks to rurun
Yobmod Jun 25, 2021
eff48b8
Import typevar in util.py
Yobmod Jun 25, 2021
17c750a
flake8 fix
Yobmod Jun 25, 2021
ff56dbb
fix typo
Yobmod Jun 25, 2021
5d7b8ba
another typo
Yobmod Jun 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
replace cast()s with asserts in remote.py
  • Loading branch information
Yobmod committed Jun 25, 2021
commit 7b09003fffa8196277bcfaa9984a3e6833805a6d
12 changes: 6 additions & 6 deletions git/refs/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,23 @@ def new(cls, oldhexsha, newhexsha, actor, time, tz_offset, message): # skipcq:
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,))
Expand Down
12 changes: 7 additions & 5 deletions git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

# 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

Expand Down Expand Up @@ -559,8 +559,8 @@ def delete_url(self, url: str, **kwargs: Any) -> 'Remote':
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:
Expand All @@ -571,14 +571,16 @@ def urls(self) -> Iterator[str]:
#
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:
Expand Down