diff options
author | Yobmod <yobmod@gmail.com> | 2021-07-05 14:11:30 +0100 |
---|---|---|
committer | Yobmod <yobmod@gmail.com> | 2021-07-05 14:11:30 +0100 |
commit | 0939e38fd8fdb0567762b8a68190f7f762cf9756 (patch) | |
tree | efe5fa989fc0b929473cb1b79ce94a09afb65742 | |
parent | e4caa80cc6b6ee2b9c031a7d743d61b4830f2a7e (diff) | |
download | gitpython-0939e38fd8fdb0567762b8a68190f7f762cf9756.tar.gz |
fix is_config_level for < 3.8
-rw-r--r-- | git/types.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/git/types.py b/git/types.py index 6604a243..69286191 100644 --- a/git/types.py +++ b/git/types.py @@ -11,7 +11,7 @@ from typing import (Callable, Dict, NoReturn, Tuple, Union, Any, Iterator, if sys.version_info[:2] >= (3, 8): from typing import Final, Literal, SupportsIndex, TypedDict, Protocol, get_args # noqa: F401 else: - from typing_extensions import Final, Literal, SupportsIndex, TypedDict, Protocol, get_args # noqa: F401 + from typing_extensions import Final, Literal, SupportsIndex, TypedDict, Protocol # noqa: F401 if sys.version_info[:2] >= (3, 10): from typing import TypeGuard # noqa: F401 @@ -51,7 +51,10 @@ ConfigLevels_Tup = Tuple[Lit_config_levels, Lit_config_levels, Lit_config_levels def is_config_level(inp: str) -> TypeGuard[Lit_config_levels]: - return inp in get_args(Lit_config_levels) + try: + return inp in get_args(Lit_config_levels) + except NameError: # get_args added in py 3.8 + return True def assert_never(inp: NoReturn, exc: Union[Exception, None] = None) -> NoReturn: |