Skip to content

Commit

Permalink
Run CPython test suite in our CI (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Mar 11, 2024
1 parent 9d1689e commit d409ec9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ jobs:
cd src
python -m unittest test_typing_extensions.py
- name: Test CPython typing test suite
run: |
# Run the typing test suite from CPython with typing_extensions installed,
# because we monkeypatch typing under some circumstances.
python -c 'import typing_extensions; import test.__main__' test_typing -v
# Test suite fails on PyPy even without typing_extensions
if: !startsWith(matrix.python-version, 'pypy')

linting:
name: Lint

Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Release 4.11.0 (WIP)
# Unreleased

- Fix minor discrepancy between error messages produced by `typing`
and `typing_extensions` on Python 3.10. Patch by Jelle Zijlstra.
- When `include_extra=False`, `get_type_hints()` now strips `ReadOnly` from the annotation.

# Release 4.10.0 (February 24, 2024)
Expand Down
4 changes: 2 additions & 2 deletions src/test_typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3262,7 +3262,7 @@ def __call__(self, *args: Unpack[Ts]) -> T: ...
self.assertEqual(MemoizedFunc.__parameters__, (Ts, T, T2))
self.assertTrue(MemoizedFunc._is_protocol)

things = "arguments" if sys.version_info >= (3, 11) else "parameters"
things = "arguments" if sys.version_info >= (3, 10) else "parameters"

# A bug was fixed in 3.11.1
# (https://github.com/python/cpython/commit/74920aa27d0c57443dd7f704d6272cca9c507ab3)
Expand Down Expand Up @@ -5711,7 +5711,7 @@ class Y(Generic[T], NamedTuple):
self.assertIsInstance(a, G)
self.assertEqual(a.x, 3)

things = "arguments" if sys.version_info >= (3, 11) else "parameters"
things = "arguments" if sys.version_info >= (3, 10) else "parameters"

with self.assertRaisesRegex(TypeError, f'Too many {things}'):
G[int, str]
Expand Down
3 changes: 2 additions & 1 deletion src/typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ def _check_generic(cls, parameters, elen=_marker):
num_tv_tuples = sum(isinstance(p, TypeVarTuple) for p in parameters)
if (num_tv_tuples > 0) and (alen >= elen - num_tv_tuples):
return
raise TypeError(f"Too {'many' if alen > elen else 'few'} parameters for {cls};"
things = "arguments" if sys.version_info >= (3, 10) else "parameters"
raise TypeError(f"Too {'many' if alen > elen else 'few'} {things} for {cls};"
f" actual {alen}, expected {elen}")


Expand Down

0 comments on commit d409ec9

Please sign in to comment.