|
38 | 38 |
|
39 | 39 | from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, TYPE_CHECKING, Union, cast, overload |
40 | 40 |
|
41 | | -from git.types import PathLike, Literal, TBD |
| 41 | +from git.types import PathLike, Literal, TBD, TypeGuard |
42 | 42 |
|
43 | 43 | if TYPE_CHECKING: |
44 | 44 | from git.repo.base import Repo |
|
48 | 48 | from git.objects.tag import TagObject |
49 | 49 |
|
50 | 50 | flagKeyLiteral = Literal[' ', '!', '+', '-', '*', '=', 't'] |
| 51 | + |
| 52 | + |
| 53 | +def is_flagKeyLiteral(inp: str) -> TypeGuard[flagKeyLiteral]: |
| 54 | + return inp in [' ', '!', '+', '-', '=', '*', 't'] |
| 55 | + |
| 56 | + |
51 | 57 | # ------------------------------------------------------------- |
52 | 58 |
|
| 59 | + |
53 | 60 | log = logging.getLogger('git.remote') |
54 | 61 | log.addHandler(logging.NullHandler()) |
55 | 62 |
|
@@ -325,7 +332,7 @@ def _from_line(cls, repo: 'Repo', line: str, fetch_line: str) -> 'FetchInfo': |
325 | 332 |
|
326 | 333 | # parse lines |
327 | 334 | control_character, operation, local_remote_ref, remote_local_ref_str, note = match.groups() |
328 | | - control_character = cast(flagKeyLiteral, control_character) # can do this neater once 3.5 dropped |
| 335 | + assert is_flagKeyLiteral(control_character) |
329 | 336 |
|
330 | 337 | try: |
331 | 338 | _new_hex_sha, _fetch_operation, fetch_note = fetch_line.split("\t") |
|
0 commit comments