Skip to content

Run CPython test suite in our CI #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 5 additions & 1 deletion src/typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ 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};"
if sys.version_info >= (3, 10):
word = "arguments"
else:
word = "parameters"
raise TypeError(f"Too {'many' if alen > elen else 'few'} {word} for {cls};"
f" actual {alen}, expected {elen}")


Expand Down