Skip to content

Commit

Permalink
Replace wildcard imports in top-level git module
Browse files Browse the repository at this point in the history
- 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.
EliahKagan committed Mar 19, 2024
1 parent abbe74d commit 7745250
Showing 1 changed file with 78 additions and 17 deletions.
95 changes: 78 additions & 17 deletions git/__init__.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@

# @PydevCodeAnalysisIgnore

__all__ = [ # noqa: F405
__all__ = [
"Actor",
"AmbiguousObjectName",
"BadName",
@@ -88,32 +88,93 @@

__version__ = "git"

from typing import List, Optional, Sequence, Tuple, Union, TYPE_CHECKING
from typing import List, Optional, Sequence, TYPE_CHECKING, Tuple, Union

from gitdb.util import to_hex_sha
from git.exc import * # noqa: F403 # @NoMove @IgnorePep8

from git.exc import (
AmbiguousObjectName,
BadName,
BadObject,
BadObjectType,
CacheError,
CheckoutError,
CommandError,
GitCommandError,
GitCommandNotFound,
GitError,
HookExecutionError,
InvalidDBRoot,
InvalidGitRepositoryError,
NoSuchPathError,
ODBError,
ParseError,
RepositoryDirtyError,
UnmergedEntriesError,
UnsafeOptionError,
UnsafeProtocolError,
UnsupportedOperation,
WorkTreeRepositoryUnsupported,
)
from git.types import PathLike

try:
from git.compat import safe_decode # @NoMove @IgnorePep8
from git.config import GitConfigParser # @NoMove @IgnorePep8
from git.objects import * # noqa: F403 # @NoMove @IgnorePep8
from git.refs import * # noqa: F403 # @NoMove @IgnorePep8
from git.diff import * # noqa: F403 # @NoMove @IgnorePep8
from git.db import * # noqa: F403 # @NoMove @IgnorePep8
from git.cmd import Git # @NoMove @IgnorePep8
from git.repo import Repo # @NoMove @IgnorePep8
from git.remote import * # noqa: F403 # @NoMove @IgnorePep8
from git.index import * # noqa: F403 # @NoMove @IgnorePep8
from git.util import ( # @NoMove @IgnorePep8
LockFile,
from git.cmd import Git # @NoMove
from git.compat import safe_decode # @NoMove
from git.config import GitConfigParser # @NoMove
from git.db import GitCmdObjectDB, GitDB # @NoMove
from git.diff import ( # @NoMove
INDEX,
NULL_TREE,
Diff,
DiffConstants,
DiffIndex,
Diffable,
)
from git.index import ( # @NoMove
BaseIndexEntry,
BlobFilter,
CheckoutError,
IndexEntry,
IndexFile,
StageType,
util, # noqa: F401 # For backward compatibility.
)
from git.objects import ( # @NoMove
Blob,
Commit,
IndexObject,
Object,
RootModule,
RootUpdateProgress,
Submodule,
TagObject,
Tree,
TreeModifier,
UpdateProgress,
)
from git.refs import ( # @NoMove
HEAD,
Head,
RefLog,
RefLogEntry,
Reference,
RemoteReference,
SymbolicReference,
Tag,
TagReference,
)
from git.remote import FetchInfo, PushInfo, Remote, RemoteProgress # @NoMove
from git.repo import Repo # @NoMove
from git.util import ( # @NoMove
Actor,
BlockingLockFile,
LockFile,
Stats,
Actor,
remove_password_if_present,
rmtree,
)
except GitError as _exc: # noqa: F405
except GitError as _exc:
raise ImportError("%s: %s" % (_exc.__class__.__name__, _exc)) from _exc

# { Initialize git executable path

0 comments on commit 7745250

Please sign in to comment.