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

Commitccbb273

Browse files
committed
Fix onerror callback type hinting, improve style
The onerror parameter of shutil.rmtree receives a 3-tuple like whatsys.exc_info() gives, not a string. Since we are not using thatparameter anyway, I've fixed it in the onerror function definedin git.util.rmtree by changing it to Any rather than hinting itnarrowly.I've also renamed the parameters so the names are based on thosethat are documented in the shutil.rmtree documentation. The namesare not part of the function's interface (this follows both fromthe documentation and the typeshed hints) but using those names maymake it easier to understand the function.- func is renamed to function.- path remains path.- exc_info is renamed to _excinfo. This parameter is documented as excinfo, but I've prepended an underscore to signifity that it is unused.These changes are to a local function and non-breaking.Finally, although not all type checkers will flag this as an errorautomatically, the git.util.rmtree function, like the shutil.rmtreefunction it calls, is conceptually void, so it should not have anyreturn statements with operands. Because the return statementappeared at the end, I've removed "return".
1 parentb8e009e commitccbb273

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎git/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,20 @@ def rmtree(path: PathLike) -> None:
182182
:note: we use shutil rmtree but adjust its behaviour to see whether files that
183183
couldn't be deleted are read-only. Windows will not remove them in that case"""
184184

185-
defonerror(func:Callable,path:PathLike,exc_info:str)->None:
185+
defonerror(function:Callable,path:PathLike,_excinfo:Any)->None:
186186
# Is the error an access error ?
187187
os.chmod(path,stat.S_IWUSR)
188188

189189
try:
190-
func(path)# Will scream if still not possible to delete.
190+
function(path)# Will scream if still not possible to delete.
191191
exceptPermissionErrorasex:
192192
ifHIDE_WINDOWS_KNOWN_ERRORS:
193193
fromunittestimportSkipTest
194194

195195
raiseSkipTest(f"FIXME: fails with: PermissionError\n{ex}")fromex
196196
raise
197197

198-
returnshutil.rmtree(path,False,onerror)
198+
shutil.rmtree(path,False,onerror)
199199

200200

201201
defrmfile(path:PathLike)->None:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp