| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -615,7 +615,7 @@ def _set_cache_(self, attr: str) -> None: | |||
| 615 | 615 | # END handle version info | |
| 616 | 616 | ||
| 617 | 617 | @property | |
| 618 | - def working_dir(self) -> Union[None, str]: | ||
| 618 | + def working_dir(self) -> Union[None, PathLike]: | ||
| 619 | 619 | """:return: Git directory we are working on""" | |
| 620 | 620 | return self._working_dir | |
| 621 | 621 | ||
@@ -1187,7 +1187,7 @@ def __get_object_header(self, cmd, ref: AnyStr) -> Tuple[str, str, int]: | |||
| 1187 | 1187 | cmd.stdin.flush() | |
| 1188 | 1188 | return self._parse_object_header(cmd.stdout.readline()) | |
| 1189 | 1189 | ||
| 1190 | - def get_object_header(self, ref: AnyStr) -> Tuple[str, str, int]: | ||
| 1190 | + def get_object_header(self, ref: str) -> Tuple[str, str, int]: | ||
| 1191 | 1191 | """ Use this method to quickly examine the type and size of the object behind | |
| 1192 | 1192 | the given ref. | |
| 1193 | 1193 | ||
@@ -1198,7 +1198,7 @@ def get_object_header(self, ref: AnyStr) -> Tuple[str, str, int]: | |||
| 1198 | 1198 | cmd = self._get_persistent_cmd("cat_file_header", "cat_file", batch_check=True) | |
| 1199 | 1199 | return self.__get_object_header(cmd, ref) | |
| 1200 | 1200 | ||
| 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]: | ||
| 1202 | 1202 | """ As get_object_header, but returns object data as well | |
| 1203 | 1203 | :return: (hexsha, type_string, size_as_int,data_string) | |
| 1204 | 1204 | :note: not threadsafe""" | |
@@ -1207,7 +1207,7 @@ def get_object_data(self, ref: AnyStr) -> Tuple[str, str, int, bytes]: | |||
| 1207 | 1207 | del(stream) | |
| 1208 | 1208 | return (hexsha, typename, size, data) | |
| 1209 | 1209 | ||
| 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']: | ||
| 1211 | 1211 | """ As get_object_header, but returns the data as a stream | |
| 1212 | 1212 | ||
| 1213 | 1213 | :return: (hexsha, type_string, size_as_int, stream) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | 13 | # typing------------------------------------------------- | |
| 14 | 14 | ||
| 15 | - from typing import TYPE_CHECKING, AnyStr | ||
| 15 | + from typing import TYPE_CHECKING | ||
| 16 | 16 | from git.types import PathLike | |
| 17 | 17 | ||
| 18 | 18 | if TYPE_CHECKING: | |
@@ -39,18 +39,18 @@ def __init__(self, root_path: PathLike, git: 'Git') -> None: | |||
| 39 | 39 | super(GitCmdObjectDB, self).__init__(root_path) | |
| 40 | 40 | self._git = git | |
| 41 | 41 | ||
| 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)) | ||
| 44 | 44 | return OInfo(hex_to_bin(hexsha), typename, size) | |
| 45 | 45 | ||
| 46 | - def stream(self, sha: bytes) -> OStream: | ||
| 46 | + def stream(self, binsha: bytes) -> OStream: | ||
| 47 | 47 | """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)) | ||
| 49 | 49 | return OStream(hex_to_bin(hexsha), typename, size, stream) | |
| 50 | 50 | ||
| 51 | 51 | # { Interface | |
| 52 | 52 | ||
| 53 | - def partial_to_complete_sha_hex(self, partial_hexsha: AnyStr) -> bytes: | ||
| 53 | + def partial_to_complete_sha_hex(self, partial_hexsha: str) -> bytes: | ||
| 54 | 54 | """:return: Full binary 20 byte sha from the given partial hexsha | |
| 55 | 55 | :raise AmbiguousObjectName: | |
| 56 | 56 | :raise BadObject: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -272,7 +272,7 @@ def merge_tree(self, rhs: Treeish, base: Union[None, Treeish] = None) -> 'IndexF | |||
| 272 | 272 | return self | |
| 273 | 273 | ||
| 274 | 274 | @classmethod | |
| 275 | - def new(cls, repo: 'Repo', *tree_sha: bytes) -> 'IndexFile': | ||
| 275 | + def new(cls, repo: 'Repo', *tree_sha: Union[str, Tree]) -> 'IndexFile': | ||
| 276 | 276 | """ Merge the given treeish revisions into a new index which is returned. | |
| 277 | 277 | This method behaves like git-read-tree --aggressive when doing the merge. | |
| 278 | 278 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,13 +11,10 @@ | |||
| 11 | 11 | ||
| 12 | 12 | # typing ---------------------------------------------------------------------- | |
| 13 | 13 | ||
| 14 | - from typing import (Any, Callable, List, Sequence, TYPE_CHECKING, Tuple, cast) | ||
| 14 | + from typing import (Any, Callable) | ||
| 15 | 15 | ||
| 16 | 16 | from git.types import PathLike | |
| 17 | 17 | ||
| 18 | - if TYPE_CHECKING: | ||
| 19 | - from git.repo import Repo | ||
| 20 | - | ||
| 21 | 18 | # --------------------------------------------------------------------------------- | |
| 22 | 19 | ||
| 23 | 20 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -97,8 +97,8 @@ def from_line(cls, line): | |||
| 97 | 97 | " Got %s" % repr(line)) | |
| 98 | 98 | # END handle first split | |
| 99 | 99 | ||
| 100 | - oldhexsha = info[:40] | ||
| 101 | - newhexsha = info[41:81] | ||
| 100 | + oldhexsha = info[:40] # type: str | ||
| 101 | + newhexsha = info[41:81] # type: str | ||
| 102 | 102 | for hexsha in (oldhexsha, newhexsha): | |
| 103 | 103 | if not cls._re_hexsha_only.match(hexsha): | |
| 104 | 104 | raise ValueError("Invalid hexsha: %r" % (hexsha,)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | 19 | # Typing ---------------------------------------------------------------------- | |
| 20 | 20 | ||
| 21 | - from typing import AnyStr, Union, Optional, cast, TYPE_CHECKING | ||
| 21 | + from typing import Union, Optional, cast, TYPE_CHECKING | ||
| 22 | 22 | from git.types import PathLike | |
| 23 | 23 | if TYPE_CHECKING: | |
| 24 | 24 | from .base import Repo | |
@@ -103,7 +103,7 @@ def find_submodule_git_dir(d: PathLike) -> Optional[PathLike]: | |||
| 103 | 103 | return None | |
| 104 | 104 | ||
| 105 | 105 | ||
| 106 | - def short_to_long(odb: 'GitCmdObjectDB', hexsha: AnyStr) -> Optional[bytes]: | ||
| 106 | + def short_to_long(odb: 'GitCmdObjectDB', hexsha: str) -> Optional[bytes]: | ||
| 107 | 107 | """:return: long hexadecimal sha1 from the given less-than-40 byte hexsha | |
| 108 | 108 | or None if no candidate could be found. | |
| 109 | 109 | :param hexsha: hexsha with less than 40 byte""" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,7 @@ | |||
| 24 | 24 | from typing import (Any, AnyStr, BinaryIO, Callable, Dict, Generator, IO, Iterator, List, | |
| 25 | 25 | Optional, Pattern, Sequence, Tuple, Union, cast, TYPE_CHECKING, overload) | |
| 26 | 26 | ||
| 27 | + import pathlib | ||
| 27 | 28 | ||
| 28 | 29 | if TYPE_CHECKING: | |
| 29 | 30 | from git.remote import Remote | |
@@ -379,7 +380,9 @@ def expand_path(p: PathLike, expand_vars: bool = ...) -> str: | |||
| 379 | 380 | ... | |
| 380 | 381 | ||
| 381 | 382 | ||
| 382 | - def expand_path(p: Union[None, PathLike], expand_vars: bool = True) -> Optional[str]: | ||
| 383 | + def expand_path(p: Union[None, PathLike], expand_vars: bool = True) -> Optional[PathLike]: | ||
| 384 | + if isinstance(p, pathlib.Path): | ||
| 385 | + return p.resolve() | ||
| 383 | 386 | try: | |
| 384 | 387 | p = osp.expanduser(p) # type: ignore | |
| 385 | 388 | if expand_vars: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments