8000 Fix Python 3.7.1 and run more versions in CI (#1076) · python/typing@83ed5bf · GitHub
[go: up one dir, main page]

Skip to content

Commit 83ed5bf

Browse files
Fix Python 3.7.1 and run more versions in CI (#1076)
1 parent 16cf672 commit 83ed5bf

File tree

4 files changed

+30
-15
lines changed

4 files changed

+30
-15
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11-dev"]
17+
# We try to test on the earliest available bugfix release of each
18+
# Python version, because typing sometimes changed between bugfix releases.
19+
# For available versions, see:
20+
# https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
21+
python-version: ["3.6", "3.6.7", "3.7", "3.7.1", "3.8", "3.8.0", "3.9", "3.9.0", "3.10", "3.10.0", "3.11-dev"]
1822

1923
runs-on: ubuntu-latest
2024

typing_extensions/CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Release 4.1.1 (February 13, 2022)
2+
3+
- Fix importing `typing_extensions` on Python 3.7.0 and 3.7.1. Original
4+
patch by Nikita Sobolev (@sobolevn).
5+
16
# Release 4.1.0 (February 12, 2022)
27

38
- Runtime support for PEP 646, adding `typing_extensions.TypeVarTuple`

typing_extensions/src/test_typing_extensions.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,13 @@ def some(arg: NoReturn) -> NoReturn: ...
131131
def some_str(arg: 'NoReturn') -> 'typing.NoReturn': ...
132132

133133
expected = {'arg': NoReturn, 'return': NoReturn}
134-
for target in [some, some_str]:
134+
targets = [some]
135+
136+
# On 3.7.0 and 3.7.1, https://github.com/python/cpython/pull/10772
137+
# wasn't applied yet and NoReturn fails _type_check.
138+
if not ((3, 7, 0) <= sys.version_info < (3, 7, 2)):
139+
targets.append(some_str)
140+
for target in targets:
135141
with self.subTest(target=target):
136142
self.assertEqual(gth(target), expected)
137143

typing_extensions/src/typing_extensions.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,26 +140,14 @@ def _collect_type_vars(types, typevar_types=None):
140140
if (
141141
isinstance(t, typevar_types) and
142142
t not in tvars and
143-
not isinstance(t, _UnpackAlias)
143+
not _is_unpack(t)
144144
):
145145
tvars.append(t)
146146
if _should_collect_from_parameters(t):
147147
tvars.extend([t for t in t.__parameters__ if t not in tvars])
148148
return tuple(tvars)
149149

150150

151-
# We have to do some monkey patching to deal with the dual nature of
152-
# Unpack/TypeVarTuple:
153-
# - We want Unpack to be a kind of TypeVar so it gets accepted in
154-
# Generic[Unpack[Ts]]
155-
# - We want it to *not* be treated as a TypeVar for the purposes of
156-
# counting generic parameters, so that when we subscript a generic,
157-
# the runtime doesn't try to substitute the Unpack with the subscripted type.
158-
if not hasattr(typing, "TypeVarTuple"):
159-
typing._collect_type_vars = _collect_type_vars
160-
typing._check_generic = _check_generic
161-
162-
163151
# 3.6.2+
164152
if hasattr(typing, 'NoReturn'):
165153
NoReturn = typing.NoReturn
@@ -2906,3 +2894,15 @@ def decorator(cls_or_fn):
29062894
}
29072895
return cls_or_fn
29082896
return decorator
2897+
2898+
2899+
# We have to do some monkey patching to deal with the dual nature of
2900+
# Unpack/TypeVarTuple:
2901+
# - We want Unpack to be a kind of TypeVar so it gets accepted in
2902+
# Generic[Unpack[Ts]]
2903+
# - We want it to *not* be treated as a TypeVar for the purposes of
2904+
# counting generic parameters, so that when we subscript a generic,
2905+
# the runtime doesn't try to substitute the Unpack with the subscripted type.
2906+
if not hasattr(typing, "TypeVarTuple"):
2907+
typing._collect_type_vars = _collect_type_vars
2908+
typing._check_generic = _check_generic

0 commit comments

Comments
 (0)
0