Skip to content

Commit 8b51af3

Browse files
committed
Improve order of imports and __all__ in git.refs submodules
1 parent 1c9bda2 commit 8b51af3

File tree

6 files changed

+33
-35
lines changed

6 files changed

+33
-35
lines changed

Diff for: git/refs/head.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
Note the distinction between the :class:`HEAD` and :class:`Head` classes.
77
"""
88

9+
__all__ = ["HEAD", "Head"]
10+
911
from git.config import GitConfigParser, SectionConstraint
10-
from git.util import join_path
1112
from git.exc import GitCommandError
13+
from git.util import join_path
1214

13-
from .symbolic import SymbolicReference
1415
from .reference import Reference
16+
from .symbolic import SymbolicReference
1517

1618
# typing ---------------------------------------------------
1719

@@ -26,8 +28,6 @@
2628

2729
# -------------------------------------------------------------------
2830

29-
__all__ = ["HEAD", "Head"]
30-
3131

3232
def strip_quotes(string: str) -> str:
3333
if string.startswith('"') and string.endswith('"'):
@@ -36,8 +36,8 @@ def strip_quotes(string: str) -> str:
3636

3737

3838
class HEAD(SymbolicReference):
39-
"""Special case of a SymbolicReference representing the repository's HEAD
40-
reference."""
39+
"""Special case of a :class:`~git.refs.symbolic.SymbolicReference` representing the
40+
repository's HEAD reference."""
4141

4242
_HEAD_NAME = "HEAD"
4343
_ORIG_HEAD_NAME = "ORIG_HEAD"

Diff for: git/refs/log.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,43 @@
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__ = ["RefLog", "RefLogEntry"]
5+
46
from mmap import mmap
7+
import os.path as osp
58
import re
69
import time as _time
710

811
from git.compat import defenc
912
from git.objects.util import (
10-
parse_date,
1113
Serializable,
1214
altz_to_utctz_str,
15+
parse_date,
1316
)
1417
from git.util import (
1518
Actor,
1619
LockedFD,
1720
LockFile,
1821
assure_directory_exists,
19-
to_native_path,
2022
bin_to_hex,
2123
file_contents_ro_filepath,
24+
to_native_path,
2225
)
2326

24-
import os.path as osp
25-
26-
2727
# typing ------------------------------------------------------------------
2828

29-
from typing import Iterator, List, Tuple, Union, TYPE_CHECKING
29+
from typing import Iterator, List, Tuple, TYPE_CHECKING, Union
3030

3131
from git.types import PathLike
3232

3333
if TYPE_CHECKING:
3434
from io import BytesIO
35-
from git.refs import SymbolicReference
35+
3636
from git.config import GitConfigParser, SectionConstraint
37+
from git.refs import SymbolicReference
3738

3839
# ------------------------------------------------------------------------------
3940

40-
__all__ = ["RefLog", "RefLogEntry"]
41-
4241

4342
class RefLogEntry(Tuple[str, str, Actor, Tuple[int, int], str]):
4443
"""Named tuple allowing easy access to the revlog data fields."""

Diff for: git/refs/reference.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
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__ = ["Reference"]
5+
46
from git.util import IterableObj, LazyMixin
7+
58
from .symbolic import SymbolicReference, T_References
69

710
# typing ------------------------------------------------------------------
@@ -15,8 +18,6 @@
1518

1619
# ------------------------------------------------------------------------------
1720

18-
__all__ = ["Reference"]
19-
2021
# { Utilities
2122

2223

@@ -34,7 +35,7 @@ def wrapper(self: T_References, *args: Any) -> _T:
3435
return wrapper
3536

3637

37-
# }END utilities
38+
# } END utilities
3839

3940

4041
class Reference(SymbolicReference, LazyMixin, IterableObj):
@@ -142,7 +143,7 @@ def iter_items(
142143
but will return non-detached references as well."""
143144
return cls._iter_items(repo, common_path)
144145

145-
# }END interface
146+
# } END interface
146147

147148
# { Remote Interface
148149

Diff for: git/refs/remote.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,23 @@
33

44
"""Module implementing a remote object allowing easy access to git remotes."""
55

6+
__all__ = ["RemoteReference"]
7+
68
import os
79

810
from git.util import join_path
911

1012
from .head import Head
1113

12-
13-
__all__ = ["RemoteReference"]
14-
1514
# typing ------------------------------------------------------------------
1615

17-
from typing import Any, Iterator, NoReturn, Union, TYPE_CHECKING
18-
from git.types import PathLike
16+
from typing import Any, Iterator, NoReturn, TYPE_CHECKING, Union
1917

18+
from git.types import PathLike
2019

2120
if TYPE_CHECKING:
21+
from git.remote import Remote
2222
from git.repo import Repo
23-
from git import Remote
2423

2524
# ------------------------------------------------------------------------------
2625

Diff for: git/refs/symbolic.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
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__ = ["SymbolicReference"]
5+
46
import os
57

8+
from gitdb.exc import BadName, BadObject
9+
610
from git.compat import defenc
7-
from git.objects import Object
11+
from git.objects.base import Object
812
from git.objects.commit import Commit
913
from git.refs.log import RefLog
1014
from git.util import (
@@ -15,7 +19,6 @@
1519
join_path_native,
1620
to_native_path_linux,
1721
)
18-
from gitdb.exc import BadName, BadObject
1922

2023
# typing ------------------------------------------------------------------
2124

@@ -30,6 +33,7 @@
3033
Union,
3134
cast,
3235
)
36+
3337
from git.types import AnyGitObject, PathLike
3438

3539
if TYPE_CHECKING:
@@ -45,9 +49,6 @@
4549
# ------------------------------------------------------------------------------
4650

4751

48-
__all__ = ["SymbolicReference"]
49-
50-
5152
def _git_dir(repo: "Repo", path: Union[PathLike, None]) -> PathLike:
5253
"""Find the git dir that is appropriate for the path."""
5354
name = f"{path}"

Diff for: git/refs/tag.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,21 @@
88
:mod:`git.objects.tag` module.
99
"""
1010

11-
from .reference import Reference
12-
1311
__all__ = ["TagReference", "Tag"]
1412

13+
from .reference import Reference
14+
1515
# typing ------------------------------------------------------------------
1616

1717
from typing import Any, TYPE_CHECKING, Type, Union
1818

1919
from git.types import AnyGitObject, PathLike
2020

2121
if TYPE_CHECKING:
22-
from git.objects import Commit
23-
from git.objects import TagObject
22+
from git.objects import Commit, TagObject
2423
from git.refs import SymbolicReference
2524
from git.repo import Repo
2625

27-
2826
# ------------------------------------------------------------------------------
2927

3028

0 commit comments

Comments
 (0)