Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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-
def working_dir(self) -> Union[None, str]:
618+
def working_dir(self) -> Union[None, PathLike]:
619619
""":return: Git directory we are working on"""
620620
return self._working_dir
621621

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

1190-
def get_object_header(self, ref: AnyStr) -> Tuple[str, str, int]:
1190+
def get_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
return self.__get_object_header(cmd, ref)
12001200

1201-
def get_object_data(self, ref: AnyStr) -> Tuple[str, str, int, bytes]:
1201+
def get_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-
def stream_object_data(self, ref: AnyStr) -> Tuple[str, str, int, 'Git.CatFileContentStream']:
1210+
def stream_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-
from typing import TYPE_CHECKING, AnyStr
15+
from typing import TYPE_CHECKING
1616
from git.types import PathLike
1717

1818
if TYPE_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-
def info(self, sha: bytes) -> OInfo:
43-
hexsha, typename, size = self._git.get_object_header(bin_to_hex(sha))
42+
def info(self, binsha: bytes) -> OInfo:
43+
hexsha, typename, size = self._git.get_object_header(bin_to_hex(binsha))
4444
return OInfo(hex_to_bin(hexsha), typename, size)
4545

46-
def stream(self, sha: bytes) -> OStream:
46+
def stream(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
return OStream(hex_to_bin(hexsha), typename, size, stream)
5050

5151
# { Interface
5252

53-
def partial_to_complete_sha_hex(self, partial_hexsha: AnyStr) -> bytes:
53+
def partial_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
from typing import Any, Iterator, List, Match, Optional, Tuple, Type, Union, TYPE_CHECKING
19-
from git.types import TBD, Final, Literal
19+
from git.types import PathLike, TBD, Final, Literal
2020

2121
if TYPE_CHECKING:
2222
from .objects.tree import Tree
@@ -84,7 +84,7 @@ def _process_diff_args(self, args: List[Union[str, 'Diffable', object]]) -> List
8484
return args
8585

8686
def diff(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-
from typing import List, Optional, Tuple, Union, TYPE_CHECKING
14+
from typing import List, Sequence, Tuple, Union, TYPE_CHECKING
1515
from git.types import PathLike
1616

1717
if TYPE_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)

AltStyle によって変換されたページ (->オリジナル) /