diff options
-rw-r--r-- | git/index/base.py | 6 | ||||
-rw-r--r-- | git/index/util.py | 6 | ||||
-rw-r--r-- | git/types.py | 1 |
3 files changed, 7 insertions, 6 deletions
diff --git a/git/index/base.py b/git/index/base.py index f4ffba7b..8346d24a 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -410,7 +410,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): # whose name contains wildcard characters. if abs_path not in resolved_paths: for f in self._iter_expand_paths(glob.glob(abs_path)): - yield f.replace(rs, '') + yield str(f).replace(rs, '') continue # END glob handling try: @@ -635,7 +635,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): @git_working_dir def _entries_for_paths(self, paths: List[str], path_rewriter: Callable, fprogress: Callable, entries: List[BaseIndexEntry]) -> List[BaseIndexEntry]: - entries_added = [] # type: List[BaseIndexEntry] + entries_added: List[BaseIndexEntry] = [] if path_rewriter: for path in paths: if osp.isabs(path): @@ -769,7 +769,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): # automatically # paths can be git-added, for everything else we use git-update-index paths, entries = self._preprocess_add_items(items) - entries_added = [] + entries_added: List[BaseIndexEntry] = [] # This code needs a working tree, therefore we try not to run it unless required. # That way, we are OK on a bare repository as well. # If there are no paths, the rewriter has nothing to do either diff --git a/git/index/util.py b/git/index/util.py index 471e9262..e0daef0c 100644 --- a/git/index/util.py +++ b/git/index/util.py @@ -13,7 +13,7 @@ import os.path as osp from typing import (Any, Callable) -from git.types import PathLike +from git.types import PathLike, _T # --------------------------------------------------------------------------------- @@ -88,12 +88,12 @@ def default_index(func: Callable[..., Any]) -> Callable[..., Any]: return check_default_index -def git_working_dir(func: Callable[..., Any]) -> Callable[..., None]: +def git_working_dir(func: Callable[..., _T]) -> Callable[..., _T]: """Decorator which changes the current working dir to the one of the git repository in order to assure relative paths are handled correctly""" @wraps(func) - def set_git_working_dir(self, *args: Any, **kwargs: Any) -> None: + def set_git_working_dir(self, *args: Any, **kwargs: Any) -> _T: cur_wd = os.getcwd() os.chdir(self.repo.working_tree_dir) try: diff --git a/git/types.py b/git/types.py index f20221b9..7b87dd18 100644 --- a/git/types.py +++ b/git/types.py @@ -30,6 +30,7 @@ if TYPE_CHECKING: # from git.refs import SymbolicReference TBD = Any +_T = TypeVar('_T') Tree_ish = Union['Commit', 'Tree'] Commit_ish = Union['Commit', 'TagObject', 'Blob', 'Tree'] |