Skip to content

Use typing-extensions only on Python < 3.8 #1218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
13 changes: 13 additions & 0 deletions git/compat/typing.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions git/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
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
Expand Down
2 changes: 1 addition & 1 deletion git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# 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:
Expand Down
2 changes: 1 addition & 1 deletion git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

# 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,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"