summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git/cmd.py4
-rw-r--r--git/compat.py18
-rw-r--r--git/diff.py5
-rw-r--r--git/index/base.py11
-rw-r--r--git/objects/submodule/base.py3
-rw-r--r--git/refs/reference.py2
-rw-r--r--git/refs/symbolic.py4
-rw-r--r--git/util.py5
8 files changed, 19 insertions, 33 deletions
diff --git a/git/cmd.py b/git/cmd.py
index f8212745..cbfde74c 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -68,7 +68,7 @@ __all__ = ('Git',)
# Documentation
## @{
-def handle_process_output(process: subprocess.Popen,
+def handle_process_output(process: Union[subprocess.Popen, 'Git.AutoInterrupt'],
stdout_handler: Union[None,
Callable[[AnyStr], None],
Callable[[List[AnyStr]], None],
@@ -77,7 +77,7 @@ def handle_process_output(process: subprocess.Popen,
Callable[[AnyStr], None],
Callable[[List[AnyStr]], None]],
finalizer: Union[None,
- Callable[[subprocess.Popen], None]] = None,
+ Callable[[Union[subprocess.Popen, 'Git.AutoInterrupt']], None]] = None,
decode_streams: bool = True) -> None:
"""Registers for notifications to learn that process output is ready to read, and dispatches lines to
the respective line handlers.
diff --git a/git/compat.py b/git/compat.py
index 7a0a15d2..988c04ef 100644
--- a/git/compat.py
+++ b/git/compat.py
@@ -29,8 +29,6 @@ from typing import (
Union,
overload,
)
-from git.types import TBD
-
# ---------------------------------------------------------------------------
@@ -97,19 +95,3 @@ def win_encode(s: Optional[AnyStr]) -> Optional[bytes]:
elif s is not None:
raise TypeError('Expected bytes or text, but got %r' % (s,))
return None
-
-
-# type: ignore ## mypy cannot understand dynamic class creation
-def with_metaclass(meta: Type[Any], *bases: Any) -> TBD:
- """copied from https://github.com/Byron/bcore/blob/master/src/python/butility/future.py#L15"""
-
- class metaclass(meta): # type: ignore
- __call__ = type.__call__
- __init__ = type.__init__ # type: ignore
-
- def __new__(cls, name: str, nbases: Optional[Tuple[int, ...]], d: Dict[str, Any]) -> TBD:
- if nbases is None:
- return type.__new__(cls, name, (), d)
- return meta(name, bases, d)
-
- return metaclass(meta.__name__ + 'Helper', None, {}) # type: ignore
diff --git a/git/diff.py b/git/diff.py
index 74ca0b64..fc16b73e 100644
--- a/git/diff.py
+++ b/git/diff.py
@@ -16,7 +16,7 @@ from .objects.util import mode_str_to_int
# typing ------------------------------------------------------------------
from typing import Any, Iterator, List, Match, Optional, Tuple, Type, TypeVar, Union, TYPE_CHECKING, cast
-from git.types import PathLike, TBD, Literal
+from git.types import PathLike, Literal
if TYPE_CHECKING:
from .objects.tree import Tree
@@ -24,6 +24,7 @@ if TYPE_CHECKING:
from git.repo.base import Repo
from git.objects.base import IndexObject
from subprocess import Popen
+ from git import Git
Lit_change_type = Literal['A', 'D', 'C', 'M', 'R', 'T', 'U']
@@ -442,7 +443,7 @@ class Diff(object):
return None
@ classmethod
- def _index_from_patch_format(cls, repo: 'Repo', proc: TBD) -> DiffIndex:
+ def _index_from_patch_format(cls, repo: 'Repo', proc: Union['Popen', 'Git.AutoInterrupt']) -> DiffIndex:
"""Create a new DiffIndex from the given text which must be in patch format
:param repo: is the repository we are operating on - it is required
:param stream: result of 'git diff' as a stream (supporting file protocol)
diff --git a/git/index/base.py b/git/index/base.py
index 6452419c..4c8b923a 100644
--- a/git/index/base.py
+++ b/git/index/base.py
@@ -70,7 +70,7 @@ from .util import (
from typing import (Any, BinaryIO, Callable, Dict, IO, Iterable, Iterator, List, NoReturn,
Sequence, TYPE_CHECKING, Tuple, Type, Union)
-from git.types import Commit_ish, PathLike, TBD
+from git.types import Commit_ish, PathLike
if TYPE_CHECKING:
from subprocess import Popen
@@ -181,7 +181,7 @@ class IndexFile(LazyMixin, git_diff.Diffable, Serializable):
self.version, self.entries, self._extension_data, _conten_sha = read_cache(stream)
return self
- def _entries_sorted(self) -> List[TBD]:
+ def _entries_sorted(self) -> List[IndexEntry]:
""":return: list of entries, in a sorted fashion, first by path, then by stage"""
return sorted(self.entries.values(), key=lambda e: (e.path, e.stage))
@@ -427,8 +427,8 @@ class IndexFile(LazyMixin, git_diff.Diffable, Serializable):
# END path exception handling
# END for each path
- def _write_path_to_stdin(self, proc: 'Popen', filepath: PathLike, item: TBD, fmakeexc: Callable[..., GitError],
- fprogress: Callable[[PathLike, bool, TBD], None],
+ def _write_path_to_stdin(self, proc: 'Popen', filepath: PathLike, item: PathLike, fmakeexc: Callable[..., GitError],
+ fprogress: Callable[[PathLike, bool, PathLike], None],
read_from_stdout: bool = True) -> Union[None, str]:
"""Write path to proc.stdin and make sure it processes the item, including progress.
@@ -492,12 +492,13 @@ class IndexFile(LazyMixin, git_diff.Diffable, Serializable):
are at stage 3 will not have a stage 3 entry.
"""
is_unmerged_blob = lambda t: t[0] != 0
- path_map: Dict[PathLike, List[Tuple[TBD, Blob]]] = {}
+ path_map: Dict[PathLike, List[Tuple[StageType, Blob]]] = {}
for stage, blob in self.iter_blobs(is_unmerged_blob):
path_map.setdefault(blob.path, []).append((stage, blob))
# END for each unmerged blob
for line in path_map.values():
line.sort()
+
return path_map
@ classmethod
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py
index 559d2585..d306c91d 100644
--- a/git/objects/submodule/base.py
+++ b/git/objects/submodule/base.py
@@ -379,6 +379,7 @@ class Submodule(IndexObject, TraversableIterableObj):
:return: The newly created submodule instance
:note: works atomically, such that no change will be done if the repository
update fails for instance"""
+
if repo.bare:
raise InvalidGitRepositoryError("Cannot add submodules to bare repositories")
# END handle bare repos
@@ -434,7 +435,7 @@ class Submodule(IndexObject, TraversableIterableObj):
url = urls[0]
else:
# clone new repo
- kwargs: Dict[str, Union[bool, int, Sequence[TBD]]] = {'n': no_checkout}
+ kwargs: Dict[str, Union[bool, int, str, Sequence[TBD]]] = {'n': no_checkout}
if not branch_is_default:
kwargs['b'] = br.name
# END setup checkout-branch
diff --git a/git/refs/reference.py b/git/refs/reference.py
index a3647fb3..2a33fbff 100644
--- a/git/refs/reference.py
+++ b/git/refs/reference.py
@@ -8,7 +8,7 @@ from .symbolic import SymbolicReference, T_References
# typing ------------------------------------------------------------------
from typing import Any, Callable, Iterator, Type, Union, TYPE_CHECKING # NOQA
-from git.types import Commit_ish, PathLike, TBD, Literal, _T # NOQA
+from git.types import Commit_ish, PathLike, _T # NOQA
if TYPE_CHECKING:
from git.repo import Repo
diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py
index b4a933aa..1c56c043 100644
--- a/git/refs/symbolic.py
+++ b/git/refs/symbolic.py
@@ -21,8 +21,8 @@ from .log import RefLog
# typing ------------------------------------------------------------------
-from typing import Any, Iterator, List, Match, Optional, Tuple, Type, TypeVar, Union, TYPE_CHECKING, cast # NOQA
-from git.types import Commit_ish, PathLike, TBD, Literal # NOQA
+from typing import Any, Iterator, List, Tuple, Type, TypeVar, Union, TYPE_CHECKING, cast # NOQA
+from git.types import Commit_ish, PathLike # NOQA
if TYPE_CHECKING:
from git.repo import Repo
diff --git a/git/util.py b/git/util.py
index 92d95379..8056804a 100644
--- a/git/util.py
+++ b/git/util.py
@@ -38,6 +38,7 @@ if TYPE_CHECKING:
from git.remote import Remote
from git.repo.base import Repo
from git.config import GitConfigParser, SectionConstraint
+ from git import Git
# from git.objects.base import IndexObject
@@ -379,7 +380,7 @@ def get_user_id() -> str:
return "%s@%s" % (getpass.getuser(), platform.node())
-def finalize_process(proc: subprocess.Popen, **kwargs: Any) -> None:
+def finalize_process(proc: Union[subprocess.Popen, 'Git.AutoInterrupt'], **kwargs: Any) -> None:
"""Wait for the process (clone, fetch, pull or push) and handle its errors accordingly"""
# TODO: No close proc-streams??
proc.wait(**kwargs)
@@ -1033,7 +1034,7 @@ class IterableList(List[T_IterableObj]):
class IterableClassWatcher(type):
""" Metaclass that watches """
- def __init__(cls, name: str, bases: List, clsdict: Dict) -> None:
+ def __init__(cls, name: str, bases: Tuple, clsdict: Dict) -> None:
for base in bases:
if type(base) == IterableClassWatcher:
warnings.warn(f"GitPython Iterable subclassed by {name}. "