Skip to content

Commit 7745250

Browse files
committed
Replace wildcard imports in top-level git module
- Use explicit imports instead of * imports. - Remove now-unneeded linter suppressions. - Alphabetize inside the try-block, though this will be undone. This currently fails to import due to a cyclic import error, so the third change, alphabetizing the imports, will have to be undone (at least in the absence of other changes). It is not merely that they should not be reordered in a way that makes them cross into or out of the try-block, but that within the try block not all orders will work. There will be more to do for backward compatibility, but the modattrs.py script, which imports the top-level git module, cannot be run until the cyclic import problem is fixed.
1 parent abbe74d commit 7745250

File tree

1 file changed

+78
-17
lines changed

1 file changed

+78
-17
lines changed

Diff for: git/__init__.py

+78-17
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# @PydevCodeAnalysisIgnore
77

8-
__all__ = [ # noqa: F405
8+
__all__ = [
99
"Actor",
1010
"AmbiguousObjectName",
1111
"BadName",
@@ -88,32 +88,93 @@
8888

8989
__version__ = "git"
9090

91-
from typing import List, Optional, Sequence, Tuple, Union, TYPE_CHECKING
91+
from typing import List, Optional, Sequence, TYPE_CHECKING, Tuple, Union
9292

9393
from gitdb.util import to_hex_sha
94-
from git.exc import * # noqa: F403 # @NoMove @IgnorePep8
94+
95+
from git.exc import (
96+
AmbiguousObjectName,
97+
BadName,
98+
BadObject,
99+
BadObjectType,
100+
CacheError,
101+
CheckoutError,
102+
CommandError,
103+
GitCommandError,
104+
GitCommandNotFound,
105+
GitError,
106+
HookExecutionError,
107+
InvalidDBRoot,
108+
InvalidGitRepositoryError,
109+
NoSuchPathError,
110+
ODBError,
111+
ParseError,
112+
RepositoryDirtyError,
113+
UnmergedEntriesError,
114+
UnsafeOptionError,
115+
UnsafeProtocolError,
116+
UnsupportedOperation,
117+
WorkTreeRepositoryUnsupported,
118+
)
95119
from git.types import PathLike
96120

97121
try:
98-
from git.compat import safe_decode # @NoMove @IgnorePep8
99-
from git.config import GitConfigParser # @NoMove @IgnorePep8
100-
from git.objects import * # noqa: F403 # @NoMove @IgnorePep8
101-
from git.refs import * # noqa: F403 # @NoMove @IgnorePep8
102-
from git.diff import * # noqa: F403 # @NoMove @IgnorePep8
103-
from git.db import * # noqa: F403 # @NoMove @IgnorePep8
104-
from git.cmd import Git # @NoMove @IgnorePep8
105-
from git.repo import Repo # @NoMove @IgnorePep8
106-
from git.remote import * # noqa: F403 # @NoMove @IgnorePep8
107-
from git.index import * # noqa: F403 # @NoMove @IgnorePep8
108-
from git.util import ( # @NoMove @IgnorePep8
109-
LockFile,
122+
from git.cmd import Git # @NoMove
123+
from git.compat import safe_decode # @NoMove
124+
from git.config import GitConfigParser # @NoMove
125+
from git.db import GitCmdObjectDB, GitDB # @NoMove
126+
from git.diff import ( # @NoMove
127+
INDEX,
128+
NULL_TREE,
129+
Diff,
130+
DiffConstants,
131+
DiffIndex,
132+
Diffable,
133+
)
134+
from git.index import ( # @NoMove
135+
BaseIndexEntry,
136+
BlobFilter,
137+
CheckoutError,
138+
IndexEntry,
139+
IndexFile,
140+
StageType,
141+
util, # noqa: F401 # For backward compatibility.
142+
)
143+
from git.objects import ( # @NoMove
144+
Blob,
145+
Commit,
146+
IndexObject,
147+
Object,
148+
RootModule,
149+
RootUpdateProgress,
150+
Submodule,
151+
TagObject,
152+
Tree,
153+
TreeModifier,
154+
UpdateProgress,
155+
)
156+
from git.refs import ( # @NoMove
157+
HEAD,
158+
Head,
159+
RefLog,
160+
RefLogEntry,
161+
Reference,
162+
RemoteReference,
163+
SymbolicReference,
164+
Tag,
165+
TagReference,
166+
)
167+
from git.remote import FetchInfo, PushInfo, Remote, RemoteProgress # @NoMove
168+
from git.repo import Repo # @NoMove
169+
from git.util import ( # @NoMove
170+
Actor,
110171
BlockingLockFile,
172+
LockFile,
111173
Stats,
112-
Actor,
113174
remove_password_if_present,
114175
rmtree,
115176
)
116-
except GitError as _exc: # noqa: F405
177+
except GitError as _exc:
117178
raise ImportError("%s: %s" % (_exc.__class__.__name__, _exc)) from _exc
118179

119180
# { Initialize git executable path

0 commit comments

Comments
 (0)