aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test
diff options
context:
space:
mode:
authorTomas R. <tomas.roun8@gmail.com>2025-03-04 20:34:59 +0100
committerGitHub <noreply@github.com>2025-03-04 11:34:59 -0800
commite091520fdbcfe406e5fdcf66b7864b2b34a6726b (patch)
tree2b7283416bbaf21cb5332534bd97ab1b8eb25ba0 /Lib/test
parentd8a1cf469e40b538a84e583ac1d5d34418ed9a6a (diff)
downloadcpython-e091520fdbcfe406e5fdcf66b7864b2b34a6726b.tar.gz
cpython-e091520fdbcfe406e5fdcf66b7864b2b34a6726b.zip
gh-126085: Add `tp_iter` to TypeAliasType to allow star unpacking (#127981)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_type_aliases.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py
index 230bbe646ba..ee1791bc1d0 100644
--- a/Lib/test/test_type_aliases.py
+++ b/Lib/test/test_type_aliases.py
@@ -5,7 +5,7 @@ from test.support import check_syntax_error, run_code
from test.typinganndata import mod_generics_cache
from typing import (
- Callable, TypeAliasType, TypeVar, TypeVarTuple, ParamSpec, get_args,
+ Callable, TypeAliasType, TypeVar, TypeVarTuple, ParamSpec, Unpack, get_args,
)
@@ -317,6 +317,17 @@ class TypeAliasTypeTest(unittest.TestCase):
self.assertEqual(mod_generics_cache.OldStyle.__module__,
mod_generics_cache.__name__)
+ def test_unpack(self):
+ type Alias = tuple[int, int]
+ unpacked = (*Alias,)[0]
+ self.assertEqual(unpacked, Unpack[Alias])
+
+ class Foo[*Ts]:
+ pass
+
+ x = Foo[str, *Alias]
+ self.assertEqual(x.__args__, (str, Unpack[Alias]))
+
# All these type aliases are used for pickling tests:
T = TypeVar('T')