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

Commit4fb6d24

Browse files
authored
Merge pull request#1880 from EliahKagan/imports
Replace all wildcard imports with explicit imports
2 parents0a609b9 +d524c76 commit4fb6d24

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

Lines changed: 97 additions & 17 deletions
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-
fromtypingimportList,Optional,Sequence,Tuple,Union,TYPE_CHECKING
91+
fromtypingimportList,Optional,Sequence,TYPE_CHECKING,Tuple,Union
9292

9393
fromgitdb.utilimportto_hex_sha
94-
fromgit.excimport*# noqa: F403 # @NoMove @IgnorePep8
94+
95+
fromgit.excimport (
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
fromgit.typesimportPathLike
96120

97121
try:
98-
fromgit.compatimportsafe_decode# @NoMove @IgnorePep8
99-
fromgit.configimportGitConfigParser# @NoMove @IgnorePep8
100-
fromgit.objectsimport*# noqa: F403 # @NoMove @IgnorePep8
101-
fromgit.refsimport*# noqa: F403 # @NoMove @IgnorePep8
102-
fromgit.diffimport*# noqa: F403 # @NoMove @IgnorePep8
103-
fromgit.dbimport*# noqa: F403 # @NoMove @IgnorePep8
104-
fromgit.cmdimportGit# @NoMove @IgnorePep8
105-
fromgit.repoimportRepo# @NoMove @IgnorePep8
106-
fromgit.remoteimport*# noqa: F403 # @NoMove @IgnorePep8
107-
fromgit.indeximport*# noqa: F403 # @NoMove @IgnorePep8
108-
fromgit.utilimport (# @NoMove @IgnorePep8
109-
LockFile,
122+
fromgit.compatimportsafe_decode# @NoMove
123+
fromgit.configimportGitConfigParser# @NoMove
124+
fromgit.objectsimport (# @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+
fromgit.refsimport (# @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+
fromgit.diffimport (# @NoMove
154+
INDEX,
155+
NULL_TREE,
156+
Diff,
157+
DiffConstants,
158+
DiffIndex,
159+
Diffable,
160+
)
161+
fromgit.dbimportGitCmdObjectDB,GitDB# @NoMove
162+
fromgit.cmdimportGit# @NoMove
163+
fromgit.repoimportRepo# @NoMove
164+
fromgit.remoteimportFetchInfo,PushInfo,Remote,RemoteProgress# @NoMove
165+
fromgit.indeximport (# @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+
fromgit.utilimport (# @NoMove
189+
Actor,
110190
BlockingLockFile,
191+
LockFile,
111192
Stats,
112-
Actor,
113193
remove_password_if_present,
114194
rmtree,
115195
)
116-
exceptGitErroras_exc:# noqa: F405
196+
exceptGitErroras_exc:
117197
raiseImportError("%s: %s"% (_exc.__class__.__name__,_exc))from_exc
118198

119199
# { Initialize git executable path

‎git/cmd.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@
55

66
from __future__importannotations
77

8-
importre
8+
__all__= ["Git"]
9+
910
importcontextlib
1011
importio
1112
importitertools
1213
importlogging
1314
importos
15+
importre
1416
importsignal
15-
fromsubprocessimportPopen,PIPE,DEVNULL
1617
importsubprocess
18+
fromsubprocessimportDEVNULL,PIPE,Popen
1719
importsys
18-
importthreading
1920
fromtextwrapimportdedent
21+
importthreading
2022

2123
fromgit.compatimportdefenc,force_bytes,safe_decode
2224
fromgit.excimport (
@@ -57,12 +59,11 @@
5759
overload,
5860
)
5961

60-
fromgit.typesimportPathLike,Literal,TBD
62+
fromgit.typesimportLiteral,PathLike,TBD
6163

6264
ifTYPE_CHECKING:
63-
fromgit.repo.baseimportRepo
6465
fromgit.diffimportDiffIndex
65-
66+
fromgit.repo.baseimportRepo
6667

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

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

8586
_logger=logging.getLogger(__name__)
8687

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

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

‎git/compat.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
importos
1515
importsys
1616

17-
fromgitdb.utils.encodingimportforce_bytes,force_text# noqa: F401 # @UnusedImport
17+
fromgitdb.utils.encodingimportforce_bytes,force_text# noqa: F401
1818

1919
# typing --------------------------------------------------------------------
2020

21-
fromtypingimport (# noqa: F401
22-
Any,
21+
fromtypingimport (
22+
Any,# noqa: F401
2323
AnyStr,
24-
Dict,
25-
IO,
24+
Dict,# noqa: F401
25+
IO,# noqa: F401
2626
Optional,
27-
Tuple,
28-
Type,
27+
Tuple,# noqa: F401
28+
Type,# noqa: F401
2929
Union,
3030
overload,
3131
)

‎git/config.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
"""Parser for reading and writing configuration files."""
77

8+
__all__= ["GitConfigParser","SectionConstraint"]
9+
810
importabc
911
importconfigparserascp
1012
importfnmatch
@@ -40,9 +42,10 @@
4042
fromgit.typesimportLit_config_levels,ConfigLevels_Tup,PathLike,assert_never,_T
4143

4244
ifTYPE_CHECKING:
43-
fromgit.repo.baseimportRepo
4445
fromioimportBytesIO
4546

47+
fromgit.repo.baseimportRepo
48+
4649
T_ConfigParser=TypeVar("T_ConfigParser",bound="GitConfigParser")
4750
T_OMD_value=TypeVar("T_OMD_value",str,bytes,int,float,bool)
4851

@@ -58,8 +61,6 @@
5861

5962
# -------------------------------------------------------------
6063

61-
__all__= ("GitConfigParser","SectionConstraint")
62-
6364
_logger=logging.getLogger(__name__)
6465

6566
CONFIG_LEVELS:ConfigLevels_Tup= ("system","user","global","repository")

‎git/db.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,26 @@
33

44
"""Module with our own gitdb implementation - it uses the git command."""
55

6-
fromgit.utilimportbin_to_hex,hex_to_bin
7-
fromgitdb.baseimportOInfo,OStream
8-
fromgitdb.dbimportGitDB
9-
fromgitdb.dbimportLooseObjectDB
6+
__all__= ["GitCmdObjectDB","GitDB"]
107

8+
fromgitdb.baseimportOInfo,OStream
9+
fromgitdb.dbimportGitDB,LooseObjectDB
1110
fromgitdb.excimportBadObject
11+
12+
fromgit.utilimportbin_to_hex,hex_to_bin
1213
fromgit.excimportGitCommandError
1314

1415
# typing-------------------------------------------------
1516

1617
fromtypingimportTYPE_CHECKING
18+
1719
fromgit.typesimportPathLike
1820

1921
ifTYPE_CHECKING:
2022
fromgit.cmdimportGit
2123

22-
2324
# --------------------------------------------------------
2425

25-
__all__= ("GitCmdObjectDB","GitDB")
26-
2726

2827
classGitCmdObjectDB(LooseObjectDB):
2928
"""A database representing the default git object store, which includes loose

‎git/diff.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
# This module is part of GitPython and is released under the
44
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55

6+
__all__= ["DiffConstants","NULL_TREE","INDEX","Diffable","DiffIndex","Diff"]
7+
68
importenum
79
importre
810

911
fromgit.cmdimporthandle_process_output
1012
fromgit.compatimportdefenc
13+
fromgit.objects.blobimportBlob
14+
fromgit.objects.utilimportmode_str_to_int
1115
fromgit.utilimportfinalize_process,hex_to_bin
1216

13-
from .objects.blobimportBlob
14-
from .objects.utilimportmode_str_to_int
15-
16-
1717
# typing ------------------------------------------------------------------
1818

1919
fromtypingimport (
@@ -23,34 +23,27 @@
2323
Match,
2424
Optional,
2525
Tuple,
26+
TYPE_CHECKING,
2627
TypeVar,
2728
Union,
28-
TYPE_CHECKING,
2929
cast,
3030
)
3131
fromgit.typesimportLiteral,PathLike
3232

3333
ifTYPE_CHECKING:
34-
from .objects.treeimportTree
35-
from .objectsimportCommit
36-
fromgit.repo.baseimportRepo
37-
fromgit.objects.baseimportIndexObject
3834
fromsubprocessimportPopen
39-
fromgitimportGit
40-
41-
Lit_change_type=Literal["A","D","C","M","R","T","U"]
4235

36+
fromgit.cmdimportGit
37+
fromgit.objects.baseimportIndexObject
38+
fromgit.objects.commitimportCommit
39+
fromgit.objects.treeimportTree
40+
fromgit.repo.baseimportRepo
4341

44-
# def is_change_type(inp: str) -> TypeGuard[Lit_change_type]:
45-
# # return True
46-
# return inp in ['A', 'D', 'C', 'M', 'R', 'T', 'U']
42+
Lit_change_type=Literal["A","D","C","M","R","T","U"]
4743

4844
# ------------------------------------------------------------------------
4945

5046

51-
__all__= ("DiffConstants","NULL_TREE","INDEX","Diffable","DiffIndex","Diff")
52-
53-
5447
@enum.unique
5548
classDiffConstants(enum.Enum):
5649
"""Special objects for :meth:`Diffable.diff`.
@@ -693,7 +686,6 @@ def _handle_diff_line(lines_bytes: bytes, repo: "Repo", index: DiffIndex) -> Non
693686
# Change type can be R100
694687
# R: status letter
695688
# 100: score (in case of copy and rename)
696-
# assert is_change_type(_change_type[0]), f"Unexpected value for change_type received: {_change_type[0]}"
697689
change_type:Lit_change_type=cast(Lit_change_type,_change_type[0])
698690
score_str="".join(_change_type[1:])
699691
score=int(score_str)ifscore_str.isdigit()elseNone

‎git/exc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@
4242
ParseError,
4343
UnsupportedOperation,
4444
)
45+
4546
fromgit.compatimportsafe_decode
4647
fromgit.utilimportremove_password_if_present
4748

4849
# typing ----------------------------------------------------
4950

50-
fromtypingimportList,Sequence,Tuple,Union,TYPE_CHECKING
51+
fromtypingimportList,Sequence,Tuple,TYPE_CHECKING,Union
52+
5153
fromgit.typesimportPathLike
5254

5355
ifTYPE_CHECKING:

‎git/index/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,14 @@
33

44
"""Initialize the index package."""
55

6-
from .baseimport*# noqa: F401 F403
7-
from .typimport*# noqa: F401 F403
6+
__all__= [
7+
"BaseIndexEntry",
8+
"BlobFilter",
9+
"CheckoutError",
10+
"IndexEntry",
11+
"IndexFile",
12+
"StageType",
13+
]
14+
15+
from .baseimportCheckoutError,IndexFile
16+
from .typimportBaseIndexEntry,BlobFilter,IndexEntry,StageType

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp