Skip to content

Commit a8b4665

Browse files
authored
Exclude broken typing-extensions version + fix import (#2460)
re. import, the ipynb code was assuming that typing-extensions would always be available, but that's not the case! There's an environment marker on the requirement meaning it won't get installed on 3.10 or higher. The test suite didn't catch this issue since aiohttp pulls in typing-extensions unconditionally.
1 parent 16275d2 commit a8b4665

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
- Parsing support has been added for unparenthesized walruses in set literals, set
1515
comprehensions, and indices (#2447).
1616
- Pin `setuptools-scm` build-time dependency version (#2457)
17+
- Exclude typing-extensions version 3.10.0.1 due to it being broken on Python 3.10
18+
(#2460)
1719

1820
### _Blackd_
1921

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ def get_long_description() -> str:
7979
"regex>=2020.1.8",
8080
"pathspec>=0.9.0, <1",
8181
"dataclasses>=0.6; python_version < '3.7'",
82-
"typing_extensions>=3.10.0.0; python_version < '3.10'",
82+
"typing_extensions>=3.10.0.0",
83+
# 3.10.0.1 is broken on at least Python 3.10,
84+
# https://github.com/python/typing/issues/865
85+
"typing_extensions!=3.10.0.1; python_version >= '3.10'",
8386
"mypy_extensions>=0.4.3",
8487
],
8588
extras_require={

src/black/handle_ipynb_magics.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
"""Functions to process IPython magics with."""
2+
23
from functools import lru_cache
34
import dataclasses
45
import ast
5-
from typing import Dict
6+
from typing import Dict, List, Tuple, Optional
67

78
import secrets
8-
from typing import List, Tuple
9+
import sys
910
import collections
1011

11-
from typing import Optional
12-
from typing_extensions import TypeGuard
12+
if sys.version_info >= (3, 10):
13+
from typing import TypeGuard
14+
else:
15+
from typing_extensions import TypeGuard
16+
1317
from black.report import NothingChanged
1418
from black.output import out
1519

0 commit comments

Comments
 (0)