Skip to content

Commit 4fb6d24

Browse files
authoredMar 19, 2024··
Merge pull request #1880 from EliahKagan/imports
Replace all wildcard imports with explicit imports
2 parents 0a609b9 + d524c76 commit 4fb6d24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+540
-419
lines changed
 

‎git/__init__.py

+97-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,112 @@
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.compat import safe_decode # @NoMove
123+
from git.config import GitConfigParser # @NoMove
124+
from git.objects import ( # @NoMove
125+
Blob,
126+
Commit,
127+
IndexObject,
128+
Object,
129+
RootModule,
130+
RootUpdateProgress,
131+
Submodule,
132+
TagObject,
133+
Tree,
134+
TreeModifier,
135+
UpdateProgress,
136+
)
137+
from git.refs import ( # @NoMove
138+
HEAD,
139+
Head,
140+
RefLog,
141+
RefLogEntry,
142+
Reference,
143+
RemoteReference,
144+
SymbolicReference,
145+
Tag,
146+
TagReference,
147+
head, # noqa: F401 # Nonpublic. May disappear! Use git.refs.head.
148+
log, # noqa: F401 # Nonpublic. May disappear! Use git.refs.log.
149+
reference, # noqa: F401 # Nonpublic. May disappear! Use git.refs.reference.
150+
symbolic, # noqa: F401 # Nonpublic. May disappear! Use git.refs.symbolic.
151+
tag, # noqa: F401 # Nonpublic. May disappear! Use git.refs.tag.
152+
)
153+
from git.diff import ( # @NoMove
154+
INDEX,
155+
NULL_TREE,
156+
Diff,
157+
DiffConstants,
158+
DiffIndex,
159+
Diffable,
160+
)
161+
from git.db import GitCmdObjectDB, GitDB # @NoMove
162+
from git.cmd import Git # @NoMove
163+
from git.repo import Repo # @NoMove
164+
from git.remote import FetchInfo, PushInfo, Remote, RemoteProgress # @NoMove
165+
from git.index import ( # @NoMove
166+
BaseIndexEntry,
167+
BlobFilter,
168+
CheckoutError,
169+
IndexEntry,
170+
IndexFile,
171+
StageType,
172+
base, # noqa: F401 # Nonpublic. May disappear! Use git.index.base.
173+
fun, # noqa: F401 # Nonpublic. May disappear! Use git.index.fun.
174+
typ, # noqa: F401 # Nonpublic. May disappear! Use git.index.typ.
175+
#
176+
# NOTE: The expression `git.util` evaluates to git.index.util, and the import
177+
# `from git import util` imports git.index.util, NOT git.util. It may not be
178+
# feasible to change this until the next major version, to avoid breaking code
179+
# inadvertently relying on it. If git.index.util really is what you want, use or
180+
# import from that name, to avoid confusion. To use the "real" git.util module,
181+
# write `from git.util import ...`, or access it as `sys.modules["git.util"]`.
182+
# (This differs from other historical indirect-submodule imports that are
183+
# unambiguously nonpublic and are subject to immediate removal. Here, the public
184+
# git.util module, even though different, makes it less discoverable that the
185+
# expression `git.util` refers to a non-public attribute of the git module.)
186+
util, # noqa: F401
187+
)
188+
from git.util import ( # @NoMove
189+
Actor,
110190
BlockingLockFile,
191+
LockFile,
111192
Stats,
112-
Actor,
113193
remove_password_if_present,
114194
rmtree,
115195
)
116-
except GitError as _exc: # noqa: F405
196+
except GitError as _exc:
117197
raise ImportError("%s: %s" % (_exc.__class__.__name__, _exc)) from _exc
118198

119199
# { Initialize git executable path

‎git/cmd.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@
55

66
from __future__ import annotations
77

8-
import re
8+
__all__ = ["Git"]
9+
910
import contextlib
1011
import io
1112
import itertools
1213
import logging
1314
import os
15+
import re
1416
import signal
15-
from subprocess import Popen, PIPE, DEVNULL
1617
import subprocess
18+
from subprocess import DEVNULL, PIPE, Popen
1719
import sys
18-
import threading
1920
from textwrap import dedent
21+
import threading
2022

2123
from git.compat import defenc, force_bytes, safe_decode
2224
from git.exc import (
@@ -57,12 +59,11 @@
5759
overload,
5860
)
5961

60-
from git.types import PathLike, Literal, TBD
62+
from git.types import Literal, PathLike, TBD
6163

6264
if TYPE_CHECKING:
63-
from git.repo.base import Repo
6465
from git.diff import DiffIndex
65-
66+
from git.repo.base import Repo
6667

6768
# ---------------------------------------------------------------------------------
6869

@@ -84,8 +85,6 @@
8485

8586
_logger = logging.getLogger(__name__)
8687

87-
__all__ = ("Git",)
88-
8988

9089
# ==============================================================================
9190
## @name Utilities

0 commit comments

Comments
 (0)