Skip to content

Commit 4a47537

Browse files
Merge branch 'main' into fix314
2 parents c98e556 + 281d7b0 commit 4a47537

File tree

6 files changed

+71
-15
lines changed

6 files changed

+71
-15
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ jobs:
3939
# https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
4040
python-version:
4141
- "3.8"
42-
- "3.8.0"
4342
- "3.9"
44-
- "3.9.0"
43+
- "3.9.12"
4544
- "3.10"
46-
- "3.10.0"
45+
- "3.10.4"
4746
- "3.11"
4847
- "3.11.0"
4948
- "3.12"
@@ -54,7 +53,7 @@ jobs:
5453
- "pypy3.9"
5554
- "pypy3.10"
5655

57-
runs-on: ubuntu-20.04
56+
runs-on: ubuntu-latest
5857

5958
steps:
6059
- uses: actions/checkout@v4
@@ -70,6 +69,7 @@ jobs:
7069
# Be wary of running `pip install` here, since it becomes easy for us to
7170
# accidentally pick up typing_extensions as installed by a dependency
7271
cd src
72+
python --version # just to make sure we're running the right one
7373
python -m unittest test_typing_extensions.py
7474
7575
- name: Test CPython typing test suite

.github/workflows/third_party.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,33 @@ jobs:
343343
--force-dep "typing-extensions @ file://$(pwd)/../typing-extensions-latest" \
344344
-- -q --nomemory --notimingintensive
345345
346+
347+
litestar:
348+
name: litestar tests
349+
needs: skip-schedule-on-fork
350+
runs-on: ubuntu-latest
351+
timeout-minutes: 10
352+
strategy:
353+
fail-fast: false
354+
matrix:
355+
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
356+
steps:
357+
- name: Setup Python
358+
uses: actions/setup-python@v5
359+
with:
360+
python-version: ${{ matrix.python-version }}
361+
- name: Checkout litestar
362+
run: git clone --depth=1 https://github.com/litestar-org/litestar.git || git clone --depth=1 https://github.com/litestar-org/litestar.git
363+
- name: Checkout typing_extensions
364+
uses: actions/checkout@v4
365+
with:
366+
path: typing-extensions-latest
367+
- name: Install uv
368+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
369+
- name: Run litestar tests
370+
run: uv run --with=../typing-extensions-latest -- python -m pytest tests/unit/test_typing.py tests/unit/test_dto
371+
working-directory: litestar
372+
346373
create-issue-on-failure:
347374
name: Create an issue if daily tests failed
348375
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
# Unreleased
22

3-
Bugfixes and changed features:
3+
- Fix `TypeError` when taking the union of `typing_extensions.TypeAliasType` and a
4+
`typing.TypeAliasType` on Python 3.12 and 3.13.
5+
Patch by [Joren Hammudoglu](https://github.com/jorenham).
6+
7+
# Release 4.13.1 (April 3, 2025)
8+
9+
Bugfixes:
410
- Fix regression in 4.13.0 on Python 3.10.2 causing a `TypeError` when using `Concatenate`.
511
Patch by [Daraan](https://github.com/Daraan).
12+
- Fix `TypeError` when using `evaluate_forward_ref` on Python 3.10.1-2 and 3.9.8-10.
13+
Patch by [Daraan](https://github.com/Daraan).
614

715
# Release 4.13.0 (March 25, 2025)
816

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "flit_core.buildapi"
66
# Project metadata
77
[project]
88
name = "typing_extensions"
9-
version = "4.13.0"
9+
version = "4.13.1"
1010
description = "Backported and Experimental Type Hints for Python 3.8+"
1111
readme = "README.md"
1212
requires-python = ">=3.8"

src/test_typing_extensions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7821,6 +7821,10 @@ def test_or(self):
78217821
self.assertEqual(Alias | None, Union[Alias, None])
78227822
self.assertEqual(Alias | (int | str), Union[Alias, int | str])
78237823
self.assertEqual(Alias | list[float], Union[Alias, list[float]])
7824+
7825+
if sys.version_info >= (3, 12):
7826+
Alias2 = typing.TypeAliasType("Alias2", str)
7827+
self.assertEqual(Alias | Alias2, Union[Alias, Alias2])
78247828
else:
78257829
with self.assertRaises(TypeError):
78267830
Alias | int

src/typing_extensions.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3827,14 +3827,27 @@ def __ror__(self, other):
38273827
TypeAliasType = typing.TypeAliasType
38283828
# 3.8-3.13
38293829
else:
3830-
def _is_unionable(obj):
3831-
"""Corresponds to is_unionable() in unionobject.c in CPython."""
3832-
return obj is None or isinstance(obj, (
3833-
type,
3834-
_types.GenericAlias,
3835-
_types.UnionType,
3836-
TypeAliasType,
3837-
))
3830+
if sys.version_info >= (3, 12):
3831+
# 3.12-3.14
3832+
def _is_unionable(obj):
3833+
"""Corresponds to is_unionable() in unionobject.c in CPython."""
3834+
return obj is None or isinstance(obj, (
3835+
type,
3836+
_types.GenericAlias,
3837+
_types.UnionType,
3838+
typing.TypeAliasType,
3839+
TypeAliasType,
3840+
))
3841+
else:
3842+
# 3.8-3.11
3843+
def _is_unionable(obj):
3844+
"""Corresponds to is_unionable() in unionobject.c in CPython."""
3845+
return obj is None or isinstance(obj, (
3846+
type,
3847+
_types.GenericAlias,
3848+
_types.UnionType,
3849+
TypeAliasType,
3850+
))
38383851

38393852
if sys.version_info < (3, 10):
38403853
# Copied and pasted from https://github.com/python/cpython/blob/986a4e1b6fcae7fe7a1d0a26aea446107dd58dd2/Objects/genericaliasobject.c#L568-L582,
@@ -4376,7 +4389,11 @@ def _lax_type_check(
43764389
A lax Python 3.11+ like version of typing._type_check
43774390
"""
43784391
if hasattr(typing, "_type_convert"):
4379-
if _FORWARD_REF_HAS_CLASS:
4392+
if (
4393+
sys.version_info >= (3, 10, 3)
4394+
or (3, 9, 10) < sys.version_info[:3] < (3, 10)
4395+
):
4396+
# allow_special_forms introduced later cpython/#30926 (bpo-46539)
43804397
type_ = typing._type_convert(
43814398
value,
43824399
module=module,

0 commit comments

Comments
 (0)