Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6471018

Browse files
committed
Improve types of @unbare_repo and @git_working_dir decorators
1 parent3ce319f commit6471018

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

‎git/index/base.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def raise_exc(e):
410410
# whose name contains wildcard characters.
411411
ifabs_pathnotinresolved_paths:
412412
forfinself._iter_expand_paths(glob.glob(abs_path)):
413-
yieldf.replace(rs,'')
413+
yieldstr(f).replace(rs,'')
414414
continue
415415
# END glob handling
416416
try:
@@ -635,7 +635,7 @@ def _store_path(self, filepath: PathLike, fprogress: Callable) -> BaseIndexEntry
635635
@git_working_dir
636636
def_entries_for_paths(self,paths:List[str],path_rewriter:Callable,fprogress:Callable,
637637
entries:List[BaseIndexEntry])->List[BaseIndexEntry]:
638-
entries_added= []# type: List[BaseIndexEntry]
638+
entries_added:List[BaseIndexEntry]= []
639639
ifpath_rewriter:
640640
forpathinpaths:
641641
ifosp.isabs(path):
@@ -769,7 +769,7 @@ def add(self, items: Sequence[Union[PathLike, Blob, BaseIndexEntry, Submodule]],
769769
# automatically
770770
# paths can be git-added, for everything else we use git-update-index
771771
paths,entries=self._preprocess_add_items(items)
772-
entries_added= []
772+
entries_added:List[BaseIndexEntry]= []
773773
# This code needs a working tree, therefore we try not to run it unless required.
774774
# That way, we are OK on a bare repository as well.
775775
# If there are no paths, the rewriter has nothing to do either

‎git/index/util.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
fromtypingimport (Any,Callable)
1515

16-
fromgit.typesimportPathLike
16+
fromgit.typesimportPathLike,_T
1717

1818
# ---------------------------------------------------------------------------------
1919

@@ -88,12 +88,12 @@ def check_default_index(self, *args: Any, **kwargs: Any) -> Any:
8888
returncheck_default_index
8989

9090

91-
defgit_working_dir(func:Callable[...,Any])->Callable[...,None]:
91+
defgit_working_dir(func:Callable[...,_T])->Callable[...,_T]:
9292
"""Decorator which changes the current working dir to the one of the git
9393
repository in order to assure relative paths are handled correctly"""
9494

9595
@wraps(func)
96-
defset_git_working_dir(self,*args:Any,**kwargs:Any)->None:
96+
defset_git_working_dir(self,*args:Any,**kwargs:Any)->_T:
9797
cur_wd=os.getcwd()
9898
os.chdir(self.repo.working_tree_dir)
9999
try:

‎git/types.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
# from git.refs import SymbolicReference
3131

3232
TBD=Any
33+
_T=TypeVar('_T')
3334

3435
Tree_ish=Union['Commit','Tree']
3536
Commit_ish=Union['Commit','TagObject','Blob','Tree']

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp