From a083e8115807ff0a9b08a81d53e56190003e5354 Mon Sep 17 00:00:00 2001 From: Jirka Date: Mon, 11 Mar 2024 11:18:06 +0100 Subject: [PATCH] try: from typing import Literal --- git/objects/blob.py | 6 +++++- git/objects/commit.py | 7 ++++++- git/objects/submodule/base.py | 7 ++++++- git/objects/tag.py | 5 ++++- git/objects/tree.py | 7 ++++++- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/git/objects/blob.py b/git/objects/blob.py index 253ceccb5..4035c3e7c 100644 --- a/git/objects/blob.py +++ b/git/objects/blob.py @@ -6,7 +6,11 @@ from mimetypes import guess_type from . import base -from git.types import Literal + +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal __all__ = ("Blob",) diff --git a/git/objects/commit.py b/git/objects/commit.py index 06ab0898b..dcb3be695 100644 --- a/git/objects/commit.py +++ b/git/objects/commit.py @@ -44,7 +44,12 @@ Dict, ) -from git.types import PathLike, Literal +from git.types import PathLike + +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal if TYPE_CHECKING: from git.repo import Repo diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index b3e681e94..e5933b116 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -44,7 +44,12 @@ from typing import Callable, Dict, Mapping, Sequence, TYPE_CHECKING, cast from typing import Any, Iterator, Union -from git.types import Commit_ish, Literal, PathLike, TBD +from git.types import Commit_ish, PathLike, TBD + +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal if TYPE_CHECKING: from git.index import IndexFile diff --git a/git/objects/tag.py b/git/objects/tag.py index f455c55fc..d8815e436 100644 --- a/git/objects/tag.py +++ b/git/objects/tag.py @@ -16,7 +16,10 @@ from typing import List, TYPE_CHECKING, Union -from git.types import Literal +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal if TYPE_CHECKING: from git.repo import Repo diff --git a/git/objects/tree.py b/git/objects/tree.py index a506bba7d..731ab5fa1 100644 --- a/git/objects/tree.py +++ b/git/objects/tree.py @@ -31,7 +31,12 @@ TYPE_CHECKING, ) -from git.types import PathLike, Literal +from git.types import PathLike + +try: + from typing import Literal +except ImportError: + from typing_extensions import Literal if TYPE_CHECKING: from git.repo import Repo