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

Commit3bb63f3

Browse files
committed
Condense FetchInfo.refresh using contextlib.suppress
I think this refactoring slightly improves readability.+ Condense/sort/group imports (while adding contextlib import).+ Minor style tweaks in FetchInfo.refresh comments.+ Make a comment in Git.refresh clearer, building on revisions in:#1810 (comment)
1 parentae28c98 commit3bb63f3

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

‎git/cmd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool:
478478
# We get here if this was the initial refresh and the refresh mode was
479479
# not error. Go ahead and set the GIT_PYTHON_GIT_EXECUTABLE such that we
480480
# discern the difference between the first refresh at import time
481-
# and subsequent calls to refresh().
481+
# and subsequent calls togit.refresh or this refresh method.
482482
cls.GIT_PYTHON_GIT_EXECUTABLE=cls.git_exec_name
483483
else:
484484
# After the first refresh (when GIT_PYTHON_GIT_EXECUTABLE is no longer

‎git/remote.py

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,24 @@
55

66
"""Module implementing a remote object allowing easy access to git remotes."""
77

8+
importcontextlib
89
importlogging
910
importre
1011

11-
fromgit.cmdimporthandle_process_output,Git
12+
fromgit.cmdimportGit,handle_process_output
1213
fromgit.compatimportdefenc,force_text
14+
fromgit.configimportGitConfigParser,SectionConstraint,cp
1315
fromgit.excimportGitCommandError
16+
fromgit.refsimportHead,Reference,RemoteReference,SymbolicReference,TagReference
1417
fromgit.utilimport (
15-
LazyMixin,
16-
IterableObj,
18+
CallableRemoteProgress,
1719
IterableList,
20+
IterableObj,
21+
LazyMixin,
1822
RemoteProgress,
19-
CallableRemoteProgress,
20-
)
21-
fromgit.utilimport (
2223
join_path,
2324
)
2425

25-
fromgit.configimport (
26-
GitConfigParser,
27-
SectionConstraint,
28-
cp,
29-
)
30-
fromgit.refsimportHead,Reference,RemoteReference,SymbolicReference,TagReference
31-
3226
# typing-------------------------------------------------------
3327

3428
fromtypingimport (
@@ -345,18 +339,13 @@ class FetchInfo(IterableObj):
345339
@classmethod
346340
defrefresh(cls)->Literal[True]:
347341
"""This gets called by the refresh function (see the top level __init__)."""
348-
#clear the old values in _flag_map
349-
try:
342+
#Clear the old values in _flag_map.
343+
withcontextlib.suppress(KeyError):
350344
delcls._flag_map["t"]
351-
exceptKeyError:
352-
pass
353-
354-
try:
345+
withcontextlib.suppress(KeyError):
355346
delcls._flag_map["-"]
356-
exceptKeyError:
357-
pass
358347

359-
#set the value given the git version
348+
#Set the value given the git version.
360349
ifGit().version_info[:2]>= (2,10):
361350
cls._flag_map["t"]=cls.TAG_UPDATE
362351
else:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp