summaryrefslogtreecommitdiff
path: root/git/remote.py
diff options
context:
space:
mode:
authorYobmod <yobmod@gmail.com>2021-06-25 20:21:59 +0100
committerYobmod <yobmod@gmail.com>2021-06-25 20:21:59 +0100
commit0eae33d324376a0a1800e51bddf7f23a343f45a1 (patch)
treeeee6a48da102afefd65f17dd53d016fb516b7d55 /git/remote.py
parenta2d9011c05b0e27f1324f393e65954542544250d (diff)
downloadgitpython-0eae33d324376a0a1800e51bddf7f23a343f45a1.tar.gz
Add is_flatLiteral() Typeguard[] to remote.py
Diffstat (limited to 'git/remote.py')
-rw-r--r--git/remote.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/git/remote.py b/git/remote.py
index a85297c1..2bf64150 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -38,7 +38,7 @@ from .refs import (
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, TYPE_CHECKING, Union, cast, overload
-from git.types import PathLike, Literal, TBD
+from git.types import PathLike, Literal, TBD, TypeGuard
if TYPE_CHECKING:
from git.repo.base import Repo
@@ -48,8 +48,15 @@ if TYPE_CHECKING:
from git.objects.tag import TagObject
flagKeyLiteral = Literal[' ', '!', '+', '-', '*', '=', 't']
+
+
+def is_flagKeyLiteral(inp: str) -> TypeGuard[flagKeyLiteral]:
+ return inp in [' ', '!', '+', '-', '=', '*', 't']
+
+
# -------------------------------------------------------------
+
log = logging.getLogger('git.remote')
log.addHandler(logging.NullHandler())
@@ -325,7 +332,7 @@ class FetchInfo(IterableObj, object):
# parse lines
control_character, operation, local_remote_ref, remote_local_ref_str, note = match.groups()
- control_character = cast(flagKeyLiteral, control_character) # can do this neater once 3.5 dropped
+ assert is_flagKeyLiteral(control_character)
try:
_new_hex_sha, _fetch_operation, fetch_note = fetch_line.split("\t")