Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: python/typing_extensions
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4.13.1
Choose a base ref
...
head repository: python/typing_extensions
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4.13.2
Choose a head ref
  • 4 commits
  • 5 files changed
  • 4 contributors

Commits on Apr 4, 2025

  1. fix TypeAliasType union with typing.TypeAliasType (#575)

    jorenham authored Apr 4, 2025
    Copy the full SHA
    8092c39 View commit details

Commits on Apr 6, 2025

  1. Add 3rd party tests for litestar (#578)

    provinzkraut authored Apr 6, 2025
    Copy the full SHA
    281d7b0 View commit details

Commits on Apr 10, 2025

  1. Do not shadow user arguments in generated __new__ by @deprecated (#…

    Viicos authored Apr 10, 2025
    Copy the full SHA
    88a0c20 View commit details
  2. Prepare release 4.13.2 (#583)

    JelleZijlstra authored Apr 10, 2025
    Copy the full SHA
    4525e9d View commit details
Showing with 85 additions and 11 deletions.
  1. +27 −0 .github/workflows/third_party.yml
  2. +10 −0 CHANGELOG.md
  3. +1 −1 pyproject.toml
  4. +23 −0 src/test_typing_extensions.py
  5. +24 −10 src/typing_extensions.py
27 changes: 27 additions & 0 deletions .github/workflows/third_party.yml
Original file line number Diff line number Diff line change
@@ -343,6 +343,33 @@ jobs:
--force-dep "typing-extensions @ file://$(pwd)/../typing-extensions-latest" \
-- -q --nomemory --notimingintensive
litestar:
name: litestar tests
needs: skip-schedule-on-fork
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Checkout litestar
run: git clone --depth=1 https://github.com/litestar-org/litestar.git || git clone --depth=1 https://github.com/litestar-org/litestar.git
- name: Checkout typing_extensions
uses: actions/checkout@v4
with:
path: typing-extensions-latest
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Run litestar tests
run: uv run --with=../typing-extensions-latest -- python -m pytest tests/unit/test_typing.py tests/unit/test_dto
working-directory: litestar

create-issue-on-failure:
name: Create an issue if daily tests failed
runs-on: ubuntu-latest
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Release 4.13.2 (April 10, 2025)

- Fix `TypeError` when taking the union of `typing_extensions.TypeAliasType` and a
`typing.TypeAliasType` on Python 3.12 and 3.13.
Patch by [Joren Hammudoglu](https://github.com/jorenham).
- Backport from CPython PR [#132160](https://github.com/python/cpython/pull/132160)
to avoid having user arguments shadowed in generated `__new__` by
`@typing_extensions.deprecated`.
Patch by [Victorien Plot](https://github.com/Viicos).

# Release 4.13.1 (April 3, 2025)

Bugfixes:
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ build-backend = "flit_core.buildapi"
# Project metadata
[project]
name = "typing_extensions"
version = "4.13.1"
version = "4.13.2"
description = "Backported and Experimental Type Hints for Python 3.8+"
readme = "README.md"
requires-python = ">=3.8"
23 changes: 23 additions & 0 deletions src/test_typing_extensions.py
Original file line number Diff line number Diff line change
@@ -707,6 +707,25 @@ class Child(Base, Mixin):
instance = Child(42)
self.assertEqual(instance.a, 42)

def test_do_not_shadow_user_arguments(self):
new_called = False
new_called_cls = None

@deprecated("MyMeta will go away soon")
class MyMeta(type):
def __new__(mcs, name, bases, attrs, cls=None):
nonlocal new_called, new_called_cls
new_called = True
new_called_cls = cls
return super().__new__(mcs, name, bases, attrs)

with self.assertWarnsRegex(DeprecationWarning, "MyMeta will go away soon"):
class Foo(metaclass=MyMeta, cls='haha'):
pass

self.assertTrue(new_called)
self.assertEqual(new_called_cls, 'haha')

def test_existing_init_subclass(self):
@deprecated("C will go away soon")
class C:
@@ -7819,6 +7838,10 @@ def test_or(self):
self.assertEqual(Alias | None, Union[Alias, None])
self.assertEqual(Alias | (int | str), Union[Alias, int | str])
self.assertEqual(Alias | list[float], Union[Alias, list[float]])

if sys.version_info >= (3, 12):
Alias2 = typing.TypeAliasType("Alias2", str)
self.assertEqual(Alias | Alias2, Union[Alias, Alias2])
else:
with self.assertRaises(TypeError):
Alias | int
34 changes: 24 additions & 10 deletions src/typing_extensions.py
Original file line number Diff line number Diff line change
@@ -3123,7 +3123,8 @@ def method(self) -> None:
return arg


if hasattr(warnings, "deprecated"):
# Python 3.13.3+ contains a fix for the wrapped __new__
if sys.version_info >= (3, 13, 3):
deprecated = warnings.deprecated
else:
_T = typing.TypeVar("_T")
@@ -3203,7 +3204,7 @@ def __call__(self, arg: _T, /) -> _T:
original_new = arg.__new__

@functools.wraps(original_new)
def __new__(cls, *args, **kwargs):
def __new__(cls, /, *args, **kwargs):
if cls is arg:
warnings.warn(msg, category=category, stacklevel=stacklevel + 1)
if original_new is not object.__new__:
@@ -3827,14 +3828,27 @@ def __ror__(self, other):
TypeAliasType = typing.TypeAliasType
# 3.8-3.13
else:
def _is_unionable(obj):
"""Corresponds to is_unionable() in unionobject.c in CPython."""
return obj is None or isinstance(obj, (
type,
_types.GenericAlias,
_types.UnionType,
TypeAliasType,
))
if sys.version_info >= (3, 12):
# 3.12-3.14
def _is_unionable(obj):
"""Corresponds to is_unionable() in unionobject.c in CPython."""
return obj is None or isinstance(obj, (
type,
_types.GenericAlias,
_types.UnionType,
typing.TypeAliasType,
TypeAliasType,
))
else:
# 3.8-3.11
def _is_unionable(obj):
"""Corresponds to is_unionable() in unionobject.c in CPython."""
return obj is None or isinstance(obj, (
type,
_types.GenericAlias,
_types.UnionType,
TypeAliasType,
))

if sys.version_info < (3, 10):
# Copied and pasted from https://github.com/python/cpython/blob/986a4e1b6fcae7fe7a1d0a26aea446107dd58dd2/Objects/genericaliasobject.c#L568-L582,