diff options
author | yobmod <yobmod@gmail.com> | 2021-03-01 20:55:08 +0000 |
---|---|---|
committer | yobmod <yobmod@gmail.com> | 2021-03-01 20:55:08 +0000 |
commit | 71e28b8e2ac1b8bc8990454721740b2073829110 (patch) | |
tree | 1e15da7683582b45d69caa59be9e6ba3caf81bed /git/db.py | |
parent | a094ac1808f7c5fa0653ac075074bb2232223ac1 (diff) | |
download | gitpython-71e28b8e2ac1b8bc8990454721740b2073829110.tar.gz |
add types to git.db and git.exc
Diffstat (limited to 'git/db.py')
-rw-r--r-- | git/db.py | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -6,12 +6,16 @@ from gitdb.base import ( ) from gitdb.db import GitDB # @UnusedImport from gitdb.db import LooseObjectDB +from gitdb.exc import BadObject -from .exc import ( - GitCommandError, - BadObject -) +from .exc import GitCommandError + +# typing------------------------------------------------- + +from .cmd import Git +from .types import PathLike, TBD +# -------------------------------------------------------- __all__ = ('GitCmdObjectDB', 'GitDB') @@ -28,23 +32,23 @@ class GitCmdObjectDB(LooseObjectDB): have packs and the other implementations """ - def __init__(self, root_path, git): + def __init__(self, root_path: PathLike, git: Git) -> None: """Initialize this instance with the root and a git command""" super(GitCmdObjectDB, self).__init__(root_path) self._git = git - def info(self, sha): + def info(self, sha: bytes) -> OInfo: hexsha, typename, size = self._git.get_object_header(bin_to_hex(sha)) return OInfo(hex_to_bin(hexsha), typename, size) - def stream(self, sha): + def stream(self, sha: bytes) -> OStream: """For now, all lookup is done by git itself""" hexsha, typename, size, stream = self._git.stream_object_data(bin_to_hex(sha)) return OStream(hex_to_bin(hexsha), typename, size, stream) # { Interface - def partial_to_complete_sha_hex(self, partial_hexsha): + def partial_to_complete_sha_hex(self, partial_hexsha: str) -> bytes: """:return: Full binary 20 byte sha from the given partial hexsha :raise AmbiguousObjectName: :raise BadObject: |