Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f6d75c5

Browse files
committed
Use typing-extensions only on Python < 3.8
All necessary attributes are available in the built-in typing module since Python 3.8. Use typing-extensions only for older versions of Python, and avoid the unnecessary dep in 3.8+.
1 parent b10de37 commit f6d75c5

File tree

7 files changed

+20
-6
lines changed

7 files changed

+20
-6
lines changed
File renamed without changes.

‎git/compat/typing.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# -*- coding: utf-8 -*-
2+
# config.py
3+
# Copyright (C) 2021 Michael Trier (mtrier@gmail.com) and contributors
4+
#
5+
# This module is part of GitPython and is released under
6+
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
7+
8+
import sys
9+
10+
if sys.version_info[:2] >= (3, 8):
11+
from typing import Final, Literal
12+
else:
13+
from typing_extensions import Final, Literal

‎git/config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616
import fnmatch
1717
from collections import OrderedDict
1818

19-
from typing_extensions import Literal
20-
2119
from git.compat import (
2220
defenc,
2321
force_text,
2422
with_metaclass,
2523
is_win,
2624
)
25+
from git.compat.typing import Literal
2726
from git.util import LockFile
2827

2928
import os.path as osp

‎git/diff.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

77
import re
8+
import sys
89
from git.cmd import handle_process_output
910
from git.compat import defenc
1011
from git.util import finalize_process, hex_to_bin
@@ -16,7 +17,7 @@
1617
# typing ------------------------------------------------------------------
1718

1819
from typing import Any, Iterator, List, Match, Optional, Tuple, Type, Union, TYPE_CHECKING
19-
from typing_extensions import Final, Literal
20+
from git.compat.typing import Final, Literal
2021
from git.types import TBD
2122

2223
if TYPE_CHECKING:

‎git/repo/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import logging
88
import os
99
import re
10+
import sys
1011
import warnings
1112

1213
from git.cmd import (
@@ -34,8 +35,8 @@
3435

3536
# typing ------------------------------------------------------
3637

38+
from git.compat.typing import Literal
3739
from git.types import TBD, PathLike
38-
from typing_extensions import Literal
3940
from typing import (Any, BinaryIO, Callable, Dict,
4041
Iterator, List, Mapping, Optional,
4142
TextIO, Tuple, Type, Union,

‎requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
gitdb>=4.0.1,<5
2-
typing-extensions>=3.7.4.0
2+
typing-extensions>=3.7.4.0;python_version<"3.8"

‎test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ tox
55
virtualenv
66
nose
77
gitdb>=4.0.1,<5
8-
typing-extensions>=3.7.4.0
8+
typing-extensions>=3.7.4.0;python_version<"3.8"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /