|
3 | 3 | # This module is part of GitPython and is released under the |
4 | 4 | # 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/ |
5 | 5 |
|
| 6 | +import sys |
| 7 | + |
| 8 | +__all__ = [ |
| 9 | + "stream_copy", |
| 10 | + "join_path", |
| 11 | + "to_native_path_linux", |
| 12 | + "join_path_native", |
| 13 | + "Stats", |
| 14 | + "IndexFileSHA1Writer", |
| 15 | + "IterableObj", |
| 16 | + "IterableList", |
| 17 | + "BlockingLockFile", |
| 18 | + "LockFile", |
| 19 | + "Actor", |
| 20 | + "get_user_id", |
| 21 | + "assure_directory_exists", |
| 22 | + "RemoteProgress", |
| 23 | + "CallableRemoteProgress", |
| 24 | + "rmtree", |
| 25 | + "unbare_repo", |
| 26 | + "HIDE_WINDOWS_KNOWN_ERRORS", |
| 27 | +] |
| 28 | + |
| 29 | +if sys.platform == "win32": |
| 30 | + __all__.append("to_native_path_windows") |
| 31 | + |
6 | 32 | from abc import abstractmethod |
7 | 33 | import contextlib |
8 | 34 | from functools import wraps |
|
16 | 42 | import shutil |
17 | 43 | import stat |
18 | 44 | import subprocess |
19 | | -import sys |
20 | 45 | import time |
21 | 46 | from urllib.parse import urlsplit, urlunsplit |
22 | 47 | import warnings |
23 | 48 |
|
| 49 | +# NOTE: Unused imports can be improved now that CI testing has fully resumed. Some of |
| 50 | +# these be used indirectly through other GitPython modules, which avoids having to write |
| 51 | +# gitdb all the time in their imports. They are not in __all__, at least currently, |
| 52 | +# because they could be removed or changed at any time, and so should not be considered |
| 53 | +# conceptually public to code outside GitPython. Linters of course do not like it. |
| 54 | +from gitdb.util import ( # noqa: F401 # @IgnorePep8 |
| 55 | + LazyMixin, # @UnusedImport |
| 56 | + LockedFD, # @UnusedImport |
| 57 | + bin_to_hex, # @UnusedImport |
| 58 | + file_contents_ro_filepath, # @UnusedImport |
| 59 | + file_contents_ro, # @UnusedImport |
| 60 | + hex_to_bin, # @UnusedImport |
| 61 | + make_sha, |
| 62 | + to_bin_sha, # @UnusedImport |
| 63 | + to_hex_sha, # @UnusedImport |
| 64 | +) |
| 65 | + |
24 | 66 | # typing --------------------------------------------------------- |
25 | 67 |
|
26 | 68 | from typing import ( |
|
37 | 79 | Pattern, |
38 | 80 | Sequence, |
39 | 81 | Tuple, |
| 82 | + TYPE_CHECKING, |
40 | 83 | TypeVar, |
41 | 84 | Union, |
42 | | - TYPE_CHECKING, |
43 | 85 | cast, |
44 | 86 | overload, |
45 | 87 | ) |
46 | 88 |
|
47 | 89 | if TYPE_CHECKING: |
| 90 | + from git.cmd import Git |
| 91 | + from git.config import GitConfigParser, SectionConstraint |
48 | 92 | from git.remote import Remote |
49 | 93 | from git.repo.base import Repo |
50 | | - from git.config import GitConfigParser, SectionConstraint |
51 | | - from git import Git |
52 | 94 |
|
53 | | -from .types import ( |
| 95 | +from git.types import ( |
| 96 | + Files_TD, |
| 97 | + Has_id_attribute, |
| 98 | + HSH_TD, |
54 | 99 | Literal, |
55 | | - SupportsIndex, |
56 | | - Protocol, |
57 | | - runtime_checkable, # because behind py version guards |
58 | 100 | PathLike, |
59 | | - HSH_TD, |
| 101 | + Protocol, |
| 102 | + SupportsIndex, |
60 | 103 | Total_TD, |
61 | | - Files_TD, # aliases |
62 | | - Has_id_attribute, |
| 104 | + runtime_checkable, |
63 | 105 | ) |
64 | 106 |
|
65 | 107 | # --------------------------------------------------------------------- |
66 | 108 |
|
67 | | -from gitdb.util import ( # noqa: F401 # @IgnorePep8 |
68 | | - make_sha, |
69 | | - LockedFD, # @UnusedImport |
70 | | - file_contents_ro, # @UnusedImport |
71 | | - file_contents_ro_filepath, # @UnusedImport |
72 | | - LazyMixin, # @UnusedImport |
73 | | - to_hex_sha, # @UnusedImport |
74 | | - to_bin_sha, # @UnusedImport |
75 | | - bin_to_hex, # @UnusedImport |
76 | | - hex_to_bin, # @UnusedImport |
77 | | -) |
78 | | - |
79 | 109 | T_IterableObj = TypeVar("T_IterableObj", bound=Union["IterableObj", "Has_id_attribute"], covariant=True) |
80 | 110 | # So IterableList[Head] is subtype of IterableList[IterableObj]. |
81 | 111 |
|
82 | | -# NOTE: Some of the unused imports might be used/imported by others. |
83 | | -# Handle once test-cases are back up and running. |
84 | | -# Most of these are unused here, but are for use by git-python modules so these |
85 | | -# don't see gitdb all the time. Flake of course doesn't like it. |
86 | | -__all__ = [ |
87 | | - "stream_copy", |
88 | | - "join_path", |
89 | | - "to_native_path_linux", |
90 | | - "join_path_native", |
91 | | - "Stats", |
92 | | - "IndexFileSHA1Writer", |
93 | | - "IterableObj", |
94 | | - "IterableList", |
95 | | - "BlockingLockFile", |
96 | | - "LockFile", |
97 | | - "Actor", |
98 | | - "get_user_id", |
99 | | - "assure_directory_exists", |
100 | | - "RemoteProgress", |
101 | | - "CallableRemoteProgress", |
102 | | - "rmtree", |
103 | | - "unbare_repo", |
104 | | - "HIDE_WINDOWS_KNOWN_ERRORS", |
105 | | -] |
106 | | - |
107 | 112 | _logger = logging.getLogger(__name__) |
108 | 113 |
|
109 | 114 |
|
@@ -292,7 +297,6 @@ def to_native_path_linux(path: PathLike) -> str: |
292 | 297 | path = str(path) |
293 | 298 | return path.replace("\\", "/") |
294 | 299 |
|
295 | | - __all__.append("to_native_path_windows") |
296 | 300 | to_native_path = to_native_path_windows |
297 | 301 | else: |
298 | 302 | # No need for any work on Linux. |
|
0 commit comments