diff options
author | Yobmod <yobmod@gmail.com> | 2021-07-06 14:45:30 +0100 |
---|---|---|
committer | Yobmod <yobmod@gmail.com> | 2021-07-06 14:45:30 +0100 |
commit | 2a6a2e2e44b6220f4cbc7d1672e0cfb1c13926c2 (patch) | |
tree | 7cf6d98a0ee447f8d109824c308f517ea94a32a1 /git/diff.py | |
parent | fb09bfacd449ac7b5d2f20b9dbe123d61d004cde (diff) | |
download | gitpython-2a6a2e2e44b6220f4cbc7d1672e0cfb1c13926c2.tar.gz |
Improve types of diff.py
Diffstat (limited to 'git/diff.py')
-rw-r--r-- | git/diff.py | 10 |
1 files changed, 6 insertions, 4 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:]) |