Skip to content

Commit c6c0812

Browse files
committed
Import TypeAlias from typing_extensions where needed
The standard library `typing` module introduced `TypeAlias` in Python 3.10. This uses it from `typing_extensions` where neederd, by making three changes: - Change the version lower bound for `typing-extensions` from 3.7.4.3 to 3.10.0.2, since 3.7.4.3 doesn't offer `TypeAlias`. (The reason not to go higher, to major version 4, is that it no longer supports versions of Python lower than 3.9, but we currently support Python 3.7 and Python 3.8.) - Require the `typing-extensions` dependency when using Python versions lower than 3.10, rather than only lower than 3.7 as before. - Conditionally import `TypeAlias` (in the `git.cmd` module) from either `typing` or `type_extensions` depending on the Python version, using a pattern that `mypy` and other type checkers recognize statically. Together with the preceding commit, this fixes #2038. (This is approach (2) described there.)
1 parent c6d16d0 commit c6c0812

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

git/cmd.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,16 @@
5555
TYPE_CHECKING,
5656
TextIO,
5757
Tuple,
58-
TypeAlias,
5958
Union,
6059
cast,
6160
overload,
6261
)
6362

63+
if sys.version_info >= (3, 10):
64+
from typing import TypeAlias
65+
else:
66+
from typing_extensions import TypeAlias
67+
6468
from git.types import Literal, PathLike, TBD
6569

6670
if TYPE_CHECKING:

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.3;python_version<"3.8"
2+
typing-extensions>=3.10.0.2;python_version<"3.10"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy