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

Commitdf8087a

Browse files
committed
Remove a large number of redundant fspaths
1 parent57a3af1 commitdf8087a

File tree

7 files changed

+14
-13
lines changed

7 files changed

+14
-13
lines changed

‎git/index/base.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ def make_exc() -> GitCommandError:
13601360
try:
13611361
self.entries[(co_path,0)]
13621362
exceptKeyError:
1363-
folder=os.fspath(co_path)
1363+
folder=co_path
13641364
ifnotfolder.endswith("/"):
13651365
folder+="/"
13661366
forentryinself.entries.values():

‎git/index/fun.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def run_commit_hook(name: str, index: "IndexFile", *args: str) -> None:
8787
return
8888

8989
env=os.environ.copy()
90-
env["GIT_INDEX_FILE"]=safe_decode(os.fspath(index.path))
90+
env["GIT_INDEX_FILE"]=safe_decode(index.path)
9191
env["GIT_EDITOR"]=":"
9292
cmd= [hp]
9393
try:

‎git/objects/submodule/base.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ def remove(
12291229
wtd=mod.working_tree_dir
12301230
delmod# Release file-handles (Windows).
12311231
gc.collect()
1232-
rmtree(str(wtd))
1232+
rmtree(wtd)
12331233
# END delete tree if possible
12341234
# END handle force
12351235

‎git/refs/symbolic.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ def _create(
706706
ifnotforceandos.path.isfile(abs_ref_path):
707707
target_data=str(target)
708708
ifisinstance(target,SymbolicReference):
709-
target_data=os.fspath(target.path)
709+
target_data=target.path
710710
ifnotresolve:
711711
target_data="ref: "+target_data
712712
withopen(abs_ref_path,"rb")asfd:
@@ -931,4 +931,4 @@ def from_path(cls: Type[T_References], repo: "Repo", path: PathLike) -> T_Refere
931931

932932
defis_remote(self)->bool:
933933
""":return: True if this symbolic reference points to a remote branch"""
934-
returnos.fspath(self.path).startswith(self._remote_common_path_default+"/")
934+
returnself.path.startswith(self._remote_common_path_default+"/")

‎git/repo/base.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class Repo:
126126
working_dir:PathLike
127127
"""The working directory of the git command."""
128128

129-
_working_tree_dir:Optional[PathLike]=None
129+
_working_tree_dir:Optional[str]=None
130130

131131
git_dir:PathLike
132132
"""The ``.git`` repository directory."""
@@ -306,7 +306,7 @@ def __init__(
306306
self._working_tree_dir=None
307307
# END working dir handling
308308

309-
self.working_dir:PathLike=self._working_tree_dirorself.common_dir
309+
self.working_dir:str=self._working_tree_dirorself.common_dir
310310
self.git=self.GitCommandWrapperType(self.working_dir)
311311

312312
# Special handling, in special times.
@@ -366,7 +366,7 @@ def description(self, descr: str) -> None:
366366
fp.write((descr+"\n").encode(defenc))
367367

368368
@property
369-
defworking_tree_dir(self)->Optional[PathLike]:
369+
defworking_tree_dir(self)->Optional[str]:
370370
"""
371371
:return:
372372
The working tree directory of our git repository.

‎git/util.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,7 @@ def _cygexpath(drive: Optional[str], path: str) -> str:
397397
p=cygpath(p)
398398
elifdrive:
399399
p="/proc/cygdrive/%s/%s"% (drive.lower(),p)
400-
p_str=os.fspath(p)# ensure it is a str and not AnyPath
401-
returnp_str.replace("\\","/")
400+
returnp.replace("\\","/")
402401

403402

404403
_cygpath_parsers:Tuple[Tuple[Pattern[str],Callable,bool], ...]= (

‎test/test_index.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,12 +579,14 @@ def mixed_iterator():
579579
iftype_id==0:# path (str)
580580
yieldentry.path
581581
eliftype_id==1:# path (PathLike)
582+
yieldPath(entry.path)
583+
eliftype_id==2:# path mock (PathLike)
582584
yieldPathLikeMock(entry.path)
583-
eliftype_id==2:# blob
585+
eliftype_id==3:# blob
584586
yieldBlob(rw_repo,entry.binsha,entry.mode,entry.path)
585-
eliftype_id==3:# BaseIndexEntry
587+
eliftype_id==4:# BaseIndexEntry
586588
yieldBaseIndexEntry(entry[:4])
587-
eliftype_id==4:# IndexEntry
589+
eliftype_id==5:# IndexEntry
588590
yieldentry
589591
else:
590592
raiseAssertionError("Invalid Type")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp