Skip to content

Commit 9f9927e

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 indicated 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, this adds explicit imports for the the Python submodules of git.refs so it is clear that they can always be accessed directly in git.refs without furhter imports if desired. For clarity, that appears first, and it 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).
1 parent 5a22913 commit 9f9927e

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

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)