diff options
-rw-r--r-- | git/diff.py | 10 | ||||
-rw-r--r-- | git/objects/submodule/base.py | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/git/diff.py b/git/diff.py index 21b66640..f07bd93a 100644 --- a/git/diff.py +++ b/git/diff.py @@ -26,8 +26,13 @@ if TYPE_CHECKING: Lit_change_type = Literal['A', 'D', 'M', 'R', 'T'] + +def is_change_type(inp: str) -> TypeGuard[Lit_change_type]: + return inp in Lit_change_type.__args__ # type: ignore + # ------------------------------------------------------------------------ + __all__ = ('Diffable', 'DiffIndex', 'Diff', 'NULL_TREE') # Special object to compare against the empty tree in diffs @@ -503,13 +508,10 @@ class Diff(object): a_blob_id: Union[str, None] b_blob_id: Union[str, None] old_mode, new_mode, a_blob_id, b_blob_id, _change_type = meta.split(None, 4) - # Change type can be R100 + # _Change_type can be R100 # R: status letter # 100: score (in case of copy and rename) - def is_change_type(inp: str) -> TypeGuard[Lit_change_type]: - return inp in Lit_change_type.__args__ # type: ignore - assert is_change_type(_change_type[0]) change_type: Lit_change_type = _change_type[0] score_str = ''.join(_change_type[1:]) diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index c975c0f5..401ef54e 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -47,6 +47,7 @@ from .util import ( find_first_remote_branch ) +from git.repo import Repo # typing ---------------------------------------------------------------------- from typing import Callable, Dict, Mapping, Sequence, TYPE_CHECKING @@ -55,7 +56,6 @@ from typing import Any, Iterator, Union from git.types import Commit_ish, PathLike, TBD if TYPE_CHECKING: - from git.repo import Repo from git.index import IndexFile |