Skip to content

Commit b11bcfa

Browse files
authored
Merge pull request #1244 from Yobmod/main
Added types to Index submodule
2 parents 33346b2 + c30bf3b commit b11bcfa

File tree

12 files changed

+276
-179
lines changed

12 files changed

+276
-179
lines changed

‎git/cmd.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ def _set_cache_(self, attr: str) -> None:
615615
# END handle version info
616616

617617
@property
618-
defworking_dir(self) ->Union[None, str]:
618+
defworking_dir(self) ->Union[None, PathLike]:
619619
""":return: Git directory we are working on"""
620620
returnself._working_dir
621621

@@ -1187,7 +1187,7 @@ def __get_object_header(self, cmd, ref: AnyStr) -> Tuple[str, str, int]:
11871187
cmd.stdin.flush()
11881188
returnself._parse_object_header(cmd.stdout.readline())
11891189

1190-
defget_object_header(self, ref: AnyStr) ->Tuple[str, str, int]:
1190+
defget_object_header(self, ref: str) ->Tuple[str, str, int]:
11911191
""" Use this method to quickly examine the type and size of the object behind
11921192
the given ref.
11931193
@@ -1198,7 +1198,7 @@ def get_object_header(self, ref: AnyStr) -> Tuple[str, str, int]:
11981198
cmd=self._get_persistent_cmd("cat_file_header", "cat_file", batch_check=True)
11991199
returnself.__get_object_header(cmd, ref)
12001200

1201-
defget_object_data(self, ref: AnyStr) ->Tuple[str, str, int, bytes]:
1201+
defget_object_data(self, ref: str) ->Tuple[str, str, int, bytes]:
12021202
""" As get_object_header, but returns object data as well
12031203
:return: (hexsha, type_string, size_as_int,data_string)
12041204
:note: not threadsafe"""
@@ -1207,7 +1207,7 @@ def get_object_data(self, ref: AnyStr) -> Tuple[str, str, int, bytes]:
12071207
del(stream)
12081208
return (hexsha, typename, size, data)
12091209

1210-
defstream_object_data(self, ref: AnyStr) ->Tuple[str, str, int, 'Git.CatFileContentStream']:
1210+
defstream_object_data(self, ref: str) ->Tuple[str, str, int, 'Git.CatFileContentStream']:
12111211
""" As get_object_header, but returns the data as a stream
12121212
12131213
:return: (hexsha, type_string, size_as_int, stream)

‎git/db.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# typing-------------------------------------------------
1414

15-
fromtypingimportTYPE_CHECKING, AnyStr
15+
fromtypingimportTYPE_CHECKING
1616
fromgit.typesimportPathLike
1717

1818
ifTYPE_CHECKING:
@@ -39,18 +39,18 @@ def __init__(self, root_path: PathLike, git: 'Git') -> None:
3939
super(GitCmdObjectDB, self).__init__(root_path)
4040
self._git=git
4141

42-
definfo(self, sha: bytes) ->OInfo:
43-
hexsha, typename, size=self._git.get_object_header(bin_to_hex(sha))
42+
definfo(self, binsha: bytes) ->OInfo:
43+
hexsha, typename, size=self._git.get_object_header(bin_to_hex(binsha))
4444
returnOInfo(hex_to_bin(hexsha), typename, size)
4545

46-
defstream(self, sha: bytes) ->OStream:
46+
defstream(self, binsha: bytes) ->OStream:
4747
"""For now, all lookup is done by git itself"""
48-
hexsha, typename, size, stream=self._git.stream_object_data(bin_to_hex(sha))
48+
hexsha, typename, size, stream=self._git.stream_object_data(bin_to_hex(binsha))
4949
returnOStream(hex_to_bin(hexsha), typename, size, stream)
5050

5151
#{Interface
5252

53-
defpartial_to_complete_sha_hex(self, partial_hexsha: AnyStr) ->bytes:
53+
defpartial_to_complete_sha_hex(self, partial_hexsha: str) ->bytes:
5454
""":return: Full binary 20 byte sha from the given partial hexsha
5555
:raise AmbiguousObjectName:
5656
:raise BadObject:

‎git/diff.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# typing ------------------------------------------------------------------
1717

1818
fromtypingimportAny, Iterator, List, Match, Optional, Tuple, Type, Union, TYPE_CHECKING
19-
fromgit.typesimportTBD, Final, Literal
19+
fromgit.typesimportPathLike, TBD, Final, Literal
2020

2121
ifTYPE_CHECKING:
2222
from .objects.treeimportTree
@@ -84,7 +84,7 @@ def _process_diff_args(self, args: List[Union[str, 'Diffable', object]]) -> List
8484
returnargs
8585

8686
defdiff(self, other: Union[Type[Index], Type['Tree'], object, None, str] =Index,
87-
paths: Union[str, List[str], Tuple[str, ...], None] =None,
87+
paths: Union[PathLike, List[PathLike], Tuple[PathLike, ...], None] =None,
8888
create_patch: bool=False, **kwargs: Any) ->'DiffIndex':
8989
"""Creates diffs between two items being trees, trees and index or an
9090
index and the working tree. It will detect renames automatically.

‎git/exc.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# typing ----------------------------------------------------
1313

14-
fromtypingimportList, Optional, Tuple, Union, TYPE_CHECKING
14+
fromtypingimportList, Sequence, Tuple, Union, TYPE_CHECKING
1515
fromgit.typesimportPathLike
1616

1717
ifTYPE_CHECKING:
@@ -113,7 +113,7 @@ class CheckoutError(GitError):
113113
were checked out successfully and hence match the version stored in the
114114
index"""
115115

116-
def__init__(self, message: str, failed_files: List[PathLike], valid_files: List[PathLike],
116+
def__init__(self, message: str, failed_files: Sequence[PathLike], valid_files: Sequence[PathLike],
117117
failed_reasons: List[str]) ->None:
118118

119119
Exception.__init__(self, message)
@@ -139,8 +139,11 @@ class HookExecutionError(CommandError):
139139
"""Thrown if a hook exits with a non-zero exit code. It provides access to the exit code and the string returned
140140
via standard output"""
141141

142-
def__init__(self, command: Union[List[str], Tuple[str, ...], str], status: Optional[str],
143-
stderr: Optional[str] =None, stdout: Optional[str] =None) ->None:
142+
def__init__(self, command: Union[List[str], Tuple[str, ...], str],
143+
status: Union[str, int, None, Exception],
144+
stderr: Union[bytes, str, None] =None,
145+
stdout: Union[bytes, str, None] =None) ->None:
146+
144147
super(HookExecutionError, self).__init__(command, status, stderr, stdout)
145148
self._msg="Hook('%s') failed%s"
146149

0 commit comments

Comments
(0)