Skip to content

Commit b25dd7e

Browse files
committed
Replace wildcard imports in git.refs
This uses explicit imports rather than wildcard imports in git.refs for names from its submodules. A comment suggested that the import order was deliberate. But each of the modules being imported from defined __all__, and there was no overlap in the names across any of them. The other main reason to import in a specific order is an order dependency in the side effects, but that does not appear to apply, at least not at this time. (In addition, at least for now, this adds explicit imports for the Python submodules of git.refs, so it is clear that they can always be accessed directly in git.refs without further imports, if desired. For clarity, those appear first, and that makes the order of the "from" imports not relevant to such side effects, due to the "from" imports no longer causing modules to be loaded for the first time. However, this is a much less important reason to consider the other imports' reordering okay, because these module imports may end up being removed later during this refactoring; their clarity benefit might not be justified, because if production code outside GitPython ill-advisedly uses wildcard imports, the bad effect of doing so could be increased.)
1 parent 8b51af3 commit b25dd7e

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

Diff for: git/refs/__init__.py

+24-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
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-
# Import all modules in order, fix the names they require.
4+
__all__ = [
5+
"head",
6+
"log",
7+
"reference",
8+
"remote",
9+
"symbolic",
10+
"tag",
11+
"HEAD",
12+
"Head",
13+
"RefLog",
14+
"RefLogEntry",
15+
"Reference",
16+
"RemoteReference",
17+
"SymbolicReference",
18+
"Tag",
19+
"TagReference",
20+
]
521

6-
from .symbolic import * # noqa: F401 F403
7-
from .reference import * # noqa: F401 F403
8-
from .head import * # noqa: F401 F403
9-
from .tag import * # noqa: F401 F403
10-
from .remote import * # noqa: F401 F403
11-
12-
from .log import * # noqa: F401 F403
22+
from . import head, log, reference, remote, symbolic, tag
23+
from .head import HEAD, Head
24+
from .log import RefLog, RefLogEntry
25+
from .reference import Reference
26+
from .remote import RemoteReference
27+
from .symbolic import SymbolicReference
28+
from .tag import Tag, TagReference

0 commit comments

Comments
 (0)