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

Commit3d4e476

Browse files
committed
Improve how second-level imports and __all__ are written
These are in the modules that are directly under the top-level gitmodule (and are not themselves subpackages, with their ownsubmodules in the Python sense), except for:- git.util, where this change was very recently made.- git.compat, where no improvements of this kind were needed.- git.types, which currently has no __all__ and will only benefit from it if what should go in it is carefully considered (and where the imports themselves are grouped, sorted, and formatted already).
1 parentb8bab43 commit3d4e476

File tree

6 files changed

+33
-34
lines changed

6 files changed

+33
-34
lines changed

‎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/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 & 13 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,29 +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
35+
36+
fromgit.cmdimportGit
37+
fromgit.objects.baseimportIndexObject
38+
fromgit.objects.commitimportCommit
39+
fromgit.objects.treeimportTree
40+
fromgit.repo.baseimportRepo
4041

4142
Lit_change_type=Literal["A","D","C","M","R","T","U"]
4243

4344
# ------------------------------------------------------------------------
4445

4546

46-
__all__= ("DiffConstants","NULL_TREE","INDEX","Diffable","DiffIndex","Diff")
47-
48-
4947
@enum.unique
5048
classDiffConstants(enum.Enum):
5149
"""Special objects for :meth:`Diffable.diff`.

‎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/remote.py

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

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

8+
__all__= ("RemoteProgress","PushInfo","FetchInfo","Remote")
9+
810
importcontextlib
911
importlogging
1012
importre
@@ -54,8 +56,6 @@
5456

5557
_logger=logging.getLogger(__name__)
5658

57-
__all__= ("RemoteProgress","PushInfo","FetchInfo","Remote")
58-
5959
# { Utilities
6060

6161

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp