Skip to content

Commit fcc7418

Browse files
committed
Don't explicitly list direct submodules in __all__
This is for non-toplevel __all__, as git.__all__ already did not do this. As noted in some of the previous commit messags that added them, omitting them might be a bit safer in terms of the impact of bugs bugs in code using GitPython, in that unexpected modules, some of which have the same name as other modules within GitPython, won't be imported due to wildcard imports from intermediate subpackages (those that are below the top-level git package/module but collect non-subpackage modules). Though it is hard to know, since some of these would have been imported before, when an __all__ was not defined at that level. However, a separate benefit of omitting them is consistency with git.__all__, which does not list the direct Python submodules of the git module. This does not affect the output of the modattrs.py script, because the attributes exist with the same objects as their values as a result of those Python submodules being imported (in "from" imports and otherwise), including when importing the top-level git module.
1 parent 00f4cbc commit fcc7418

File tree

5 files changed

+2
-31
lines changed

5 files changed

+2
-31
lines changed

git/index/__init__.py

-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
"""Initialize the index package."""
55

66
__all__ = [
7-
"base",
8-
"fun",
9-
"typ",
10-
"util",
117
"BaseIndexEntry",
128
"BlobFilter",
139
"CheckoutError",
@@ -16,6 +12,5 @@
1612
"StageType",
1713
]
1814

19-
from . import base, fun, typ, util
2015
from .base import CheckoutError, IndexFile
2116
from .typ import BaseIndexEntry, BlobFilter, IndexEntry, StageType

git/objects/__init__.py

-7
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44
"""Import all submodules' main classes into the package space."""
55

66
__all__ = [
7-
"base",
8-
"blob",
9-
"commit",
10-
"submodule",
11-
"tag",
12-
"tree",
137
"IndexObject",
148
"Object",
159
"Blob",
@@ -23,7 +17,6 @@
2317
"TreeModifier",
2418
]
2519

26-
from . import base, blob, commit, submodule, tag, tree
2720
from .base import IndexObject, Object
2821
from .blob import Blob
2922
from .commit import Commit

git/objects/submodule/__init__.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
# This module is part of GitPython and is released under the
22
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
33

4-
__all__ = [
5-
"base",
6-
"root",
7-
"util",
8-
"Submodule",
9-
"UpdateProgress",
10-
"RootModule",
11-
"RootUpdateProgress",
12-
]
4+
__all__ = ["Submodule", "UpdateProgress", "RootModule", "RootUpdateProgress"]
135

14-
from . import base, root, util
156
from .base import Submodule, UpdateProgress
167
from .root import RootModule, RootUpdateProgress

git/refs/__init__.py

-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
33

44
__all__ = [
5-
"head",
6-
"log",
7-
"reference",
8-
"remote",
9-
"symbolic",
10-
"tag",
115
"HEAD",
126
"Head",
137
"RefLog",
@@ -19,7 +13,6 @@
1913
"TagReference",
2014
]
2115

22-
from . import head, log, reference, remote, symbolic, tag
2316
from .head import HEAD, Head
2417
from .log import RefLog, RefLogEntry
2518
from .reference import Reference

git/repo/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
"""Initialize the repo package."""
55

6-
__all__ = ["base", "fun", "Repo"]
6+
__all__ = ["Repo"]
77

8-
from . import base, fun
98
from .base import Repo

0 commit comments

Comments
 (0)