Skip to content

Commit 966baaa

Browse files
authored
Only require typing-extensions if Python < 3.8 (#1873)
1 parent f07832e commit 966baaa

File tree

5 files changed

+105
-7
lines changed

5 files changed

+105
-7
lines changed

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ pathspec = ">=0.6"
2929
regex = ">=2020.1.8"
3030
toml = ">=0.10.1"
3131
typed-ast = "==1.4.2"
32-
typing_extensions = ">=3.7.4"
32+
typing_extensions = {"python_version <" = "3.8","version >=" = "3.7.4"}
3333
black = {editable = true,extras = ["d"],path = "."}
3434
dataclasses = {"python_version <" = "3.7","version >" = "0.6"}

Pipfile.lock

Lines changed: 92 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def get_long_description() -> str:
7575
"regex>=2020.1.8",
7676
"pathspec>=0.6, <1",
7777
"dataclasses>=0.6; python_version < '3.7'",
78-
"typing_extensions>=3.7.4",
78+
"typing_extensions>=3.7.4; python_version < '3.8'",
7979
"mypy_extensions>=0.4.3",
8080
],
8181
extras_require={

src/black/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
cast,
4343
TYPE_CHECKING,
4444
)
45-
from typing_extensions import Final
4645
from mypy_extensions import mypyc_attr
4746

4847
from appdirs import user_cache_dir
@@ -61,6 +60,11 @@
6160

6261
from _black_version import version as __version__
6362

63+
if sys.version_info < (3, 8):
64+
from typing_extensions import Final
65+
else:
66+
from typing import Final
67+
6468
if TYPE_CHECKING:
6569
import colorama # noqa: F401
6670

src/blib2to3/pgen2/token.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
"""Token constants (from "token.h")."""
22

3+
import sys
34
from typing import Dict
4-
from typing_extensions import Final
5+
6+
if sys.version_info < (3, 8):
7+
from typing_extensions import Final
8+
else:
9+
from typing import Final
510

611
# Taken from Python (r53757) and modified to include some tokens
712
# originally monkeypatched in by pgen2.tokenize

0 commit comments

Comments
 (0)