summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git/diff.py2
-rw-r--r--git/types.py8
2 files changed, 5 insertions, 5 deletions
diff --git a/git/diff.py b/git/diff.py
index f07bd93a..611194a8 100644
--- a/git/diff.py
+++ b/git/diff.py
@@ -28,7 +28,7 @@ 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
+ return inp in ('A', 'D', 'M', 'R', 'T')
# ------------------------------------------------------------------------
diff --git a/git/types.py b/git/types.py
index 7b87dd18..b2a555b0 100644
--- a/git/types.py
+++ b/git/types.py
@@ -38,6 +38,10 @@ Commit_ish = Union['Commit', 'TagObject', 'Blob', 'Tree']
Lit_config_levels = Literal['system', 'global', 'user', 'repository']
+def is_config_level(inp: str) -> TypeGuard[Lit_config_levels]:
+ return inp in ('system', 'global', 'user', 'repository')
+
+
class ConfigLevels_NT(NamedTuple):
"""NamedTuple of allowed CONFIG_LEVELS"""
# works for pylance, but not mypy
@@ -51,10 +55,6 @@ ConfigLevels_Tup = Tuple[Lit_config_levels, Lit_config_levels, Lit_config_levels
# Typing this as specific literals breaks for mypy
-def is_config_level(inp: str) -> TypeGuard[Lit_config_levels]:
- return inp in Lit_config_levels.__args__ # type: ignore # mypy lies about __args__
-
-
def assert_never(inp: NoReturn, exc: Union[Exception, None] = None) -> NoReturn:
if exc is None:
assert False, f"An unhandled Literal ({inp}) in an if else chain was found"