diff options
author | Yobmod <yobmod@gmail.com> | 2021-07-06 14:25:23 +0100 |
---|---|---|
committer | Yobmod <yobmod@gmail.com> | 2021-07-06 14:25:23 +0100 |
commit | 647101833ae276f3b923583e202faa3f7d78e218 (patch) | |
tree | 298db9f851fe2f4adc4e48554ca2a79f6faf2da8 /git/index | |
parent | 3ce319f1296a5402079e9280500e96cc1d12fd04 (diff) | |
download | gitpython-647101833ae276f3b923583e202faa3f7d78e218.tar.gz |
Improve types of @unbare_repo and @git_working_dir decorators
Diffstat (limited to 'git/index')
-rw-r--r-- | git/index/base.py | 6 | ||||
-rw-r--r-- | git/index/util.py | 6 |
2 files changed, 6 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: |