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

Commit4e9a2f2

Browse files
committed
Improve order of imports and __all__ in git.object.submodule.*
1 parentc946906 commit4e9a2f2

File tree

8 files changed

+68
-59
lines changed

8 files changed

+68
-59
lines changed

‎git/objects/base.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +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-
importgitdb.typasdbtyp
6+
__all__= ("Object","IndexObject")
7+
78
importos.pathasosp
89

10+
importgitdb.typasdbtyp
11+
912
fromgit.excimportWorkTreeRepositoryUnsupported
10-
fromgit.utilimportLazyMixin,join_path_native,stream_copy,bin_to_hex
13+
fromgit.utilimportLazyMixin,bin_to_hex,join_path_native,stream_copy
1114

1215
from .utilimportget_object_type_by_name
1316

14-
1517
# typing ------------------------------------------------------------------
1618

1719
fromtypingimportAny,TYPE_CHECKING,Union
@@ -24,16 +26,14 @@
2426
fromgit.refs.referenceimportReference
2527
fromgit.repoimportRepo
2628

27-
from .treeimportTree
2829
from .blobimportBlob
2930
from .submodule.baseimportSubmodule
31+
from .treeimportTree
3032

3133
IndexObjUnion=Union["Tree","Blob","Submodule"]
3234

3335
# --------------------------------------------------------------------------
3436

35-
__all__= ("Object","IndexObject")
36-
3737

3838
classObject(LazyMixin):
3939
"""Base class for classes representing git object types.

‎git/objects/blob.py

Lines changed: 3 additions & 3 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__= ("Blob",)
7+
68
frommimetypesimportguess_type
79
importsys
810

9-
from .importbase
10-
1111
ifsys.version_info>= (3,8):
1212
fromtypingimportLiteral
1313
else:
1414
fromtyping_extensionsimportLiteral
1515

16-
__all__= ("Blob",)
16+
from .importbase
1717

1818

1919
classBlob(base.IndexObject):

‎git/objects/commit.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
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__= ("Commit",)
7+
68
fromcollectionsimportdefaultdict
79
importdatetime
810
fromioimportBytesIO
@@ -14,10 +16,12 @@
1416
fromtimeimportaltzone,daylight,localtime,time,timezone
1517

1618
fromgitdbimportIStream
19+
1720
fromgit.cmdimportGit
1821
fromgit.diffimportDiffable
19-
fromgit.utilimporthex_to_bin,Actor,Stats,finalize_process
22+
fromgit.utilimportActor,Stats,finalize_process,hex_to_bin
2023

24+
from .importbase
2125
from .treeimportTree
2226
from .utilimport (
2327
Serializable,
@@ -27,7 +31,6 @@
2731
parse_actor_and_date,
2832
parse_date,
2933
)
30-
from .importbase
3134

3235
# typing ------------------------------------------------------------------
3336

@@ -59,8 +62,6 @@
5962

6063
_logger=logging.getLogger(__name__)
6164

62-
__all__= ("Commit",)
63-
6465

6566
classCommit(base.Object,TraversableIterableObj,Diffable,Serializable):
6667
"""Wraps a git commit object.

‎git/objects/fun.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33

44
"""Functions that are supposed to be as fast as possible."""
55

6-
fromstatimportS_ISDIR
6+
__all__= (
7+
"tree_to_stream",
8+
"tree_entries_from_data",
9+
"traverse_trees_recursive",
10+
"traverse_tree_recursive",
11+
)
712

13+
fromstatimportS_ISDIR
814

915
fromgit.compatimportsafe_decode,defenc
1016

@@ -23,22 +29,15 @@
2329

2430
ifTYPE_CHECKING:
2531
from_typeshedimportReadableBuffer
32+
2633
fromgitimportGitCmdObjectDB
2734

28-
EntryTup=Tuple[bytes,int,str]#same as TreeCacheTup in tree.py
35+
EntryTup=Tuple[bytes,int,str]#Same as TreeCacheTup in tree.py.
2936
EntryTupOrNone=Union[EntryTup,None]
3037

3138
# ---------------------------------------------------
3239

3340

34-
__all__= (
35-
"tree_to_stream",
36-
"tree_entries_from_data",
37-
"traverse_trees_recursive",
38-
"traverse_tree_recursive",
39-
)
40-
41-
4241
deftree_to_stream(entries:Sequence[EntryTup],write:Callable[["ReadableBuffer"],Union[int,None]])->None:
4342
"""Write the given list of entries into a stream using its ``write`` method.
4443

‎git/objects/submodule/util.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@
2323
fromgit.typesimportPathLike
2424

2525
ifTYPE_CHECKING:
26-
from .baseimportSubmodule
2726
fromweakrefimportReferenceType
27+
28+
fromgit.refsimportHead,RemoteReference
29+
fromgit.remoteimportRemote
2830
fromgit.repoimportRepo
29-
fromgit.refsimportHead
30-
fromgitimportRemote
31-
fromgit.refsimportRemoteReference
31+
32+
from .baseimportSubmodule
3233

3334
# { Utilities
3435

‎git/objects/tag.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@
99
For lightweight tags, see the :mod:`git.refs.tag` module.
1010
"""
1111

12+
__all__= ("TagObject",)
13+
1214
importsys
1315

16+
fromgit.compatimportdefenc
17+
fromgit.utilimporthex_to_bin
18+
1419
from .importbase
1520
from .utilimportget_object_type_by_name,parse_actor_and_date
16-
from ..utilimporthex_to_bin
17-
from ..compatimportdefenc
21+
22+
# typing ----------------------------------------------
1823

1924
fromtypingimportList,TYPE_CHECKING,Union
2025

@@ -26,11 +31,12 @@
2631
ifTYPE_CHECKING:
2732
fromgit.repoimportRepo
2833
fromgit.utilimportActor
29-
from .commitimportCommit
34+
3035
from .blobimportBlob
36+
from .commitimportCommit
3137
from .treeimportTree
3238

33-
__all__= ("TagObject",)
39+
# ---------------------------------------------------
3440

3541

3642
classTagObject(base.Object):

‎git/objects/tree.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
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__= ("TreeModifier","Tree")
7+
68
importsys
79

810
importgit.diffasgit_diff
911
fromgit.utilimportIterableList,join_path,to_bin_sha
1012

13+
from .importutil
1114
from .baseimportIndexObjUnion,IndexObject
1215
from .blobimportBlob
1316
from .funimporttree_entries_from_data,tree_to_stream
1417
from .submodule.baseimportSubmodule
15-
from .importutil
1618

1719
# typing -------------------------------------------------
1820

@@ -39,23 +41,20 @@
3941

4042
ifTYPE_CHECKING:
4143
fromioimportBytesIO
44+
4245
fromgit.repoimportRepo
4346

4447
TreeCacheTup=Tuple[bytes,int,str]
4548

4649
TraversedTreeTup=Union[Tuple[Union["Tree",None],IndexObjUnion,Tuple["Submodule","Submodule"]]]
4750

48-
4951
# def is_tree_cache(inp: Tuple[bytes, int, str]) -> TypeGuard[TreeCacheTup]:
5052
# return isinstance(inp[0], bytes) and isinstance(inp[1], int) and isinstance([inp], str)
5153

5254
# --------------------------------------------------------
5355

54-
5556
cmp:Callable[[str,str],int]=lambdaa,b: (a>b)- (a<b)
5657

57-
__all__= ("TreeModifier","Tree")
58-
5958

6059
classTreeModifier:
6160
"""A utility class providing methods to alter the underlying cache in a list-like

‎git/objects/util.py

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,63 @@
55

66
"""General utility functions."""
77

8+
__all__= (
9+
"get_object_type_by_name",
10+
"parse_date",
11+
"parse_actor_and_date",
12+
"ProcessStreamAdapter",
13+
"Traversable",
14+
"altz_to_utctz_str",
15+
"utctz_to_altz",
16+
"verify_utctz",
17+
"Actor",
18+
"tzoffset",
19+
"utc",
20+
)
21+
822
fromabcimportABC,abstractmethod
923
importcalendar
1024
fromcollectionsimportdeque
1125
fromdatetimeimportdatetime,timedelta,tzinfo
12-
fromstringimportdigits
1326
importre
27+
fromstringimportdigits
1428
importtime
1529
importwarnings
1630

17-
fromgit.utilimportIterableList,IterableObj,Actor
31+
fromgit.utilimportActor,IterableList,IterableObj
1832

1933
# typing ------------------------------------------------------------
34+
2035
fromtypingimport (
2136
Any,
2237
Callable,
2338
Deque,
24-
Iterator,
2539
# Generic,
40+
Iterator,
2641
NamedTuple,
27-
overload,
2842
Sequence,
2943
TYPE_CHECKING,
3044
Tuple,
3145
Type,
3246
TypeVar,
3347
Union,
3448
cast,
49+
overload,
3550
)
3651

3752
fromgit.typesimportHas_id_attribute,Literal# , _T
3853

3954
ifTYPE_CHECKING:
4055
fromioimportBytesIO,StringIO
41-
from .commitimportCommit
42-
from .blobimportBlob
43-
from .tagimportTagObject
44-
from .treeimportTree,TraversedTreeTup
4556
fromsubprocessimportPopen
46-
from .submodule.baseimportSubmodule
57+
4758
fromgit.typesimportProtocol,runtime_checkable
59+
60+
from .blobimportBlob
61+
from .commitimportCommit
62+
from .submodule.baseimportSubmodule
63+
from .tagimportTagObject
64+
from .treeimportTraversedTreeTup,Tree
4865
else:
4966
# Protocol = Generic[_T] # Needed for typing bug #572?
5067
Protocol=ABC
@@ -68,20 +85,6 @@ class TraverseNT(NamedTuple):
6885

6986
# --------------------------------------------------------------------
7087

71-
__all__= (
72-
"get_object_type_by_name",
73-
"parse_date",
74-
"parse_actor_and_date",
75-
"ProcessStreamAdapter",
76-
"Traversable",
77-
"altz_to_utctz_str",
78-
"utctz_to_altz",
79-
"verify_utctz",
80-
"Actor",
81-
"tzoffset",
82-
"utc",
83-
)
84-
8588
ZERO=timedelta(0)
8689

8790
# { Functions

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp