summaryrefslogtreecommitdiff
path: root/git/db.py
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2021-03-17 17:49:09 +0800
committerGitHub <noreply@github.com>2021-03-17 17:49:09 +0800
commit6643a9feb39d4d49c894c1d25e3d4d71e180208a (patch)
tree002c4c12c1da90f1889672942cdb500ad0dce47d /git/db.py
parent690722a611a25a1afcdb0163d3cfd0a8c89d1d04 (diff)
parentc93e971f3e0aa4dea12a0cb169539fe85681e381 (diff)
downloadgitpython-6643a9feb39d4d49c894c1d25e3d4d71e180208a.tar.gz
Merge pull request #1202 from Yobmod/main
Add more types
Diffstat (limited to 'git/db.py')
-rw-r--r--git/db.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/git/db.py b/git/db.py
index de2e9991..73051abf 100644
--- a/git/db.py
+++ b/git/db.py
@@ -7,11 +7,19 @@ from gitdb.base import (
from gitdb.db import GitDB # @UnusedImport
from gitdb.db import LooseObjectDB
-from .exc import (
- GitCommandError,
- BadObject
-)
+from gitdb.exc import BadObject
+from git.exc import GitCommandError
+
+# typing-------------------------------------------------
+
+from typing import TYPE_CHECKING, AnyStr
+from git.types import PathLike
+
+if TYPE_CHECKING:
+ from git.cmd import Git
+
+# --------------------------------------------------------
__all__ = ('GitCmdObjectDB', 'GitDB')
@@ -28,23 +36,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: AnyStr) -> bytes:
""":return: Full binary 20 byte sha from the given partial hexsha
:raise AmbiguousObjectName:
:raise BadObject: