diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2021-04-24 10:00:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-24 10:00:40 +0800 |
commit | 730177174bbc721fba8fbdcd28aa347b3ad75576 (patch) | |
tree | d9f504fe5a7b0e0c4332ae31b48adfd391d3e7f5 | |
parent | 4119a576251448793c07ebd080534948cad2f170 (diff) | |
parent | 9448c082b158dcab960d33982e8189f2d2da4729 (diff) | |
download | gitpython-730177174bbc721fba8fbdcd28aa347b3ad75576.tar.gz |
Merge pull request #1218 from mgorny/typing-ext
Use typing-extensions only on Python < 3.8
-rw-r--r-- | git/compat/__init__.py (renamed from git/compat.py) | 0 | ||||
-rw-r--r-- | git/compat/typing.py | 13 | ||||
-rw-r--r-- | git/config.py | 3 | ||||
-rw-r--r-- | git/diff.py | 2 | ||||
-rw-r--r-- | git/repo/base.py | 2 | ||||
-rw-r--r-- | requirements.txt | 2 | ||||
-rw-r--r-- | test-requirements.txt | 2 |
7 files changed, 18 insertions, 6 deletions
diff --git a/git/compat.py b/git/compat/__init__.py index c4bd2aa3..c4bd2aa3 100644 --- a/git/compat.py +++ b/git/compat/__init__.py diff --git a/git/compat/typing.py b/git/compat/typing.py new file mode 100644 index 00000000..925c5ba2 --- /dev/null +++ b/git/compat/typing.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +# config.py +# Copyright (C) 2021 Michael Trier (mtrier@gmail.com) and contributors +# +# This module is part of GitPython and is released under +# the BSD License: http://www.opensource.org/licenses/bsd-license.php + +import sys + +if sys.version_info[:2] >= (3, 8): + from typing import Final, Literal # noqa: F401 +else: + from typing_extensions import Final, Literal # noqa: F401 diff --git a/git/config.py b/git/config.py index 1cb80475..0c8d975d 100644 --- a/git/config.py +++ b/git/config.py @@ -16,14 +16,13 @@ import re import fnmatch from collections import OrderedDict -from typing_extensions import Literal - from git.compat import ( defenc, force_text, with_metaclass, is_win, ) +from git.compat.typing import Literal from git.util import LockFile import os.path as osp diff --git a/git/diff.py b/git/diff.py index deedb635..943916ea 100644 --- a/git/diff.py +++ b/git/diff.py @@ -16,7 +16,7 @@ from .objects.util import mode_str_to_int # typing ------------------------------------------------------------------ from typing import Any, Iterator, List, Match, Optional, Tuple, Type, Union, TYPE_CHECKING -from typing_extensions import Final, Literal +from git.compat.typing import Final, Literal from git.types import TBD if TYPE_CHECKING: diff --git a/git/repo/base.py b/git/repo/base.py index b1d0cdbc..ed0a810e 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -34,8 +34,8 @@ import gitdb # typing ------------------------------------------------------ +from git.compat.typing import Literal from git.types import TBD, PathLike -from typing_extensions import Literal from typing import (Any, BinaryIO, Callable, Dict, Iterator, List, Mapping, Optional, TextIO, Tuple, Type, Union, diff --git a/requirements.txt b/requirements.txt index 626a916a..d980f668 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ gitdb>=4.0.1,<5 -typing-extensions>=3.7.4.0 +typing-extensions>=3.7.4.0;python_version<"3.8" diff --git a/test-requirements.txt b/test-requirements.txt index 0734820f..e06d2be1 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -5,4 +5,4 @@ tox virtualenv nose gitdb>=4.0.1,<5 -typing-extensions>=3.7.4.0 +typing-extensions>=3.7.4.0;python_version<"3.8" |