summaryrefslogtreecommitdiff
path: root/git/index/util.py
diff options
context:
space:
mode:
authorYobmod <yobmod@gmail.com>2021-07-08 21:42:30 +0100
committerYobmod <yobmod@gmail.com>2021-07-08 21:42:30 +0100
commit5d3818ed3d51d400517a352b5b62e966164af8cf (patch)
treef58e6f846ec24da39ac05f3f44a752f1addece80 /git/index/util.py
parent2e2fe186d09272c3cb6c96467fff362deb90994f (diff)
downloadgitpython-5d3818ed3d51d400517a352b5b62e966164af8cf.tar.gz
Finish initial typing of index folder
Diffstat (limited to 'git/index/util.py')
-rw-r--r--git/index/util.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/git/index/util.py b/git/index/util.py
index 3b3d6489..4f8af553 100644
--- a/git/index/util.py
+++ b/git/index/util.py
@@ -11,10 +11,13 @@ import os.path as osp
# typing ----------------------------------------------------------------------
-from typing import (Any, Callable)
+from typing import (Any, Callable, TYPE_CHECKING)
from git.types import PathLike, _T
+if TYPE_CHECKING:
+ from git.index import IndexFile
+
# ---------------------------------------------------------------------------------
@@ -63,7 +66,7 @@ def post_clear_cache(func: Callable[..., _T]) -> Callable[..., _T]:
"""
@wraps(func)
- def post_clear_cache_if_not_raised(self, *args: Any, **kwargs: Any) -> _T:
+ def post_clear_cache_if_not_raised(self: 'IndexFile', *args: Any, **kwargs: Any) -> _T:
rval = func(self, *args, **kwargs)
self._delete_entries_cache()
return rval
@@ -78,7 +81,7 @@ def default_index(func: Callable[..., _T]) -> Callable[..., _T]:
on that index only. """
@wraps(func)
- def check_default_index(self, *args: Any, **kwargs: Any) -> _T:
+ def check_default_index(self: 'IndexFile', *args: Any, **kwargs: Any) -> _T:
if self._file_path != self._index_path():
raise AssertionError(
"Cannot call %r on indices that do not represent the default git index" % func.__name__)
@@ -93,9 +96,9 @@ def git_working_dir(func: Callable[..., _T]) -> Callable[..., _T]:
repository in order to assure relative paths are handled correctly"""
@wraps(func)
- def set_git_working_dir(self, *args: Any, **kwargs: Any) -> _T:
+ def set_git_working_dir(self: 'IndexFile', *args: Any, **kwargs: Any) -> _T:
cur_wd = os.getcwd()
- os.chdir(self.repo.working_tree_dir)
+ os.chdir(str(self.repo.working_tree_dir))
try:
return func(self, *args, **kwargs)
finally: