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

Commit8434967

Browse files
committed
Fix type hints
1 parent12e15ba commit8434967

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

‎git/index/base.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ def _iter_expand_paths(self: "IndexFile", paths: Sequence[PathLike]) -> Iterator
404404
defraise_exc(e:Exception)->NoReturn:
405405
raisee
406406

407-
r=os.fspath(self.repo.working_tree_dir)
407+
r=str(self.repo.working_tree_dir)
408408
rs=r+os.sep
409409
forpathinpaths:
410410
abs_path=os.fspath(path)
@@ -656,7 +656,7 @@ def _to_relative_path(self, path: PathLike) -> PathLike:
656656
returnpath
657657
ifself.repo.bare:
658658
raiseInvalidGitRepositoryError("require non-bare repository")
659-
ifnotosp.normpath(path).startswith(os.fspath(self.repo.working_tree_dir)):
659+
ifnotosp.normpath(path).startswith(str(self.repo.working_tree_dir)):
660660
raiseValueError("Absolute path %r is not in git repository at %r"% (path,self.repo.working_tree_dir))
661661
result=os.path.relpath(path,self.repo.working_tree_dir)
662662
ifos.fspath(path).endswith(os.sep)andnotresult.endswith(os.sep):
@@ -731,7 +731,7 @@ def _entries_for_paths(
731731
forpathinpaths:
732732
ifosp.isabs(path):
733733
abspath=path
734-
gitrelative_path=path[len(os.fspath(self.repo.working_tree_dir))+1 :]
734+
gitrelative_path=path[len(str(self.repo.working_tree_dir))+1 :]
735735
else:
736736
gitrelative_path=path
737737
ifself.repo.working_tree_dir:
@@ -1036,7 +1036,7 @@ def remove(
10361036
args.append("--")
10371037

10381038
# Preprocess paths.
1039-
paths=self._items_to_rela_paths(items)
1039+
paths=list(map(os.fspath,self._items_to_rela_paths(items)))# type: ignore[arg-type]
10401040
removed_paths=self.repo.git.rm(args,paths,**kwargs).splitlines()
10411041

10421042
# Process output to gain proper paths.
@@ -1363,7 +1363,7 @@ def make_exc() -> GitCommandError:
13631363
ifnotfolder.endswith("/"):
13641364
folder+="/"
13651365
forentryinself.entries.values():
1366-
ifentry.path.startswith(folder):
1366+
ifos.fspath(entry.path).startswith(folder):
13671367
p=entry.path
13681368
self._write_path_to_stdin(proc,p,p,make_exc,fprogress,read_from_stdout=False)
13691369
checked_out_files.append(p)

‎git/index/util.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# typing ----------------------------------------------------------------------
1717

18-
fromtypingimportAny,Callable,TYPE_CHECKING,Optional,Type
18+
fromtypingimportAny,Callable,TYPE_CHECKING,Optional,Type,cast
1919

2020
fromgit.typesimportLiteral,PathLike,_T
2121

@@ -106,7 +106,7 @@ def git_working_dir(func: Callable[..., _T]) -> Callable[..., _T]:
106106
@wraps(func)
107107
defset_git_working_dir(self:"IndexFile",*args:Any,**kwargs:Any)->_T:
108108
cur_wd=os.getcwd()
109-
os.chdir(self.repo.working_tree_dir)
109+
os.chdir(cast(PathLike,self.repo.working_tree_dir))
110110
try:
111111
returnfunc(self,*args,**kwargs)
112112
finally:

‎git/objects/submodule/base.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def _clone_repo(
352352
module_abspath_dir=osp.dirname(module_abspath)
353353
ifnotosp.isdir(module_abspath_dir):
354354
os.makedirs(module_abspath_dir)
355-
module_checkout_path=osp.join(repo.working_tree_dir,path)
355+
module_checkout_path=osp.join(repo.working_tree_dir,path)# type: ignore[arg-type]
356356

357357
ifurl.startswith("../"):
358358
remote_name=cast("RemoteReference",repo.active_branch.tracking_branch()).remote_name

‎git/refs/symbolic.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def _get_ref_info_helper(
236236
tokens:Union[None,List[str],Tuple[str,str]]=None
237237
repodir=_git_dir(repo,ref_path)
238238
try:
239-
withopen(os.path.join(repodir,ref_path),"rt",encoding="UTF-8")asfp:
239+
withopen(os.path.join(repodir,ref_path),"rt",encoding="UTF-8")asfp:# type: ignore[arg-type]
240240
value=fp.read().rstrip()
241241
# Don't only split on spaces, but on whitespace, which allows to parse lines like:
242242
# 60b64ef992065e2600bfef6187a97f92398a9144 branch 'master' of git-server:/path/to/repo

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp