Skip to content

typing ParamSpec #5837

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 6 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .cspell.dict/python-more.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ basicsize
bdfl
bigcharset
bignum
bivariant
breakpointhook
cformat
chunksize
Expand Down
10 changes: 0 additions & 10 deletions Lib/test/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,6 @@ def test_instancecheck_and_subclasscheck(self):
self.assertTrue(issubclass(dict, x))
self.assertFalse(issubclass(list, x))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_instancecheck_and_subclasscheck_order(self):
T = typing.TypeVar('T')

Expand Down Expand Up @@ -790,17 +788,13 @@ def __subclasscheck__(cls, sub):
self.assertTrue(issubclass(int, x))
self.assertRaises(ZeroDivisionError, issubclass, list, x)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_or_type_operator_with_TypeVar(self):
TV = typing.TypeVar('T')
assert TV | str == typing.Union[TV, str]
assert str | TV == typing.Union[str, TV]
self.assertIs((int | TV)[int], int)
self.assertIs((TV | int)[int], int)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_union_args(self):
def check(arg, expected):
clear_typing_caches()
Expand Down Expand Up @@ -893,16 +887,12 @@ def test_union_copy(self):
self.assertEqual(copied.__args__, orig.__args__)
self.assertEqual(copied.__parameters__, orig.__parameters__)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_union_parameter_substitution_errors(self):
T = typing.TypeVar("T")
x = int | T
with self.assertRaises(TypeError):
x[int, str]

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_or_type_operator_with_forward(self):
T = typing.TypeVar('T')
ForwardAfter = T | 'Forward'
Expand Down
14 changes: 0 additions & 14 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,6 @@ def test_union_unique(self):
self.assertEqual(Union[X, int].__parameters__, (X,))
self.assertIs(Union[X, int].__origin__, Union)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_or(self):
X = TypeVar('X')
# use a string because str doesn't implement
Expand Down Expand Up @@ -657,7 +655,6 @@ class X[T]: ...
self.assertFalse(T.has_default())

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_paramspec(self):
P = ParamSpec('P', default=(str, int))
self.assertEqual(P.__default__, (str, int))
Expand Down Expand Up @@ -686,7 +683,6 @@ class X[**P]: ...
self.assertFalse(P.has_default())

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_typevartuple(self):
Ts = TypeVarTuple('Ts', default=Unpack[Tuple[str, int]])
self.assertEqual(Ts.__default__, Unpack[Tuple[str, int]])
Expand Down Expand Up @@ -1289,15 +1285,13 @@ class Gen[*Ts]: ...
class TypeVarTupleTests(BaseTestCase):

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_name(self):
Ts = TypeVarTuple('Ts')
self.assertEqual(Ts.__name__, 'Ts')
Ts2 = TypeVarTuple('Ts2')
self.assertEqual(Ts2.__name__, 'Ts2')

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_module(self):
Ts = TypeVarTuple('Ts')
self.assertEqual(Ts.__module__, __name__)
Expand Down Expand Up @@ -2050,7 +2044,6 @@ class TypeVarTuplePicklingTests(BaseTestCase):
# statements at the start of each test.

# TODO: RUSTPYTHON
@unittest.expectedFailure
@all_pickle_protocols
def test_pickling_then_unpickling_results_in_same_identity(self, proto):
global global_Ts1 # See explanation at start of class.
Expand Down Expand Up @@ -4278,7 +4271,6 @@ class Node(Generic[T]): ...
self.assertEqual(t, deepcopy(t))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_immutability_by_copy_and_pickle(self):
# Special forms like Union, Any, etc., generic aliases to containers like List,
# Mapping, etc., and type variabcles are considered immutable by copy and pickle.
Expand Down Expand Up @@ -8801,7 +8793,6 @@ def test_cannot_subscript(self):
class ParamSpecTests(BaseTestCase):

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_basic_plain(self):
P = ParamSpec('P')
self.assertEqual(P, P)
Expand Down Expand Up @@ -9010,7 +9001,6 @@ class Y(Generic[P, T]):
self.assertEqual(B.__args__, ((int, str,), Tuple[bytes, float]))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_var_substitution(self):
P = ParamSpec("P")
subst = P.__typing_subst__
Expand All @@ -9022,7 +9012,6 @@ def test_var_substitution(self):
self.assertEqual(subst(Concatenate[int, P]), Concatenate[int, P])

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_bad_var_substitution(self):
T = TypeVar('T')
P = ParamSpec('P')
Expand Down Expand Up @@ -9241,7 +9230,6 @@ def test_dir(self):
self.assertIn(required_item, dir_items)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_valid_uses(self):
P = ParamSpec('P')
T = TypeVar('T')
Expand Down Expand Up @@ -9719,8 +9707,6 @@ def test_constructor(self):
with self.assertRaises(TypeError):
type(NoDefault)(1)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_repr(self):
self.assertEqual(repr(NoDefault), 'typing.NoDefault')

Expand Down
2 changes: 1 addition & 1 deletion vm/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ impl ExecutingFrame<'_> {
bytecode::Instruction::TypeVarTuple => {
let type_var_tuple_name = self.pop_value();
let type_var_tuple: PyObjectRef =
_typing::make_typevartuple(type_var_tuple_name.clone())
_typing::make_typevartuple(type_var_tuple_name.clone(), vm)
.into_ref(&vm.ctx)
.into();
self.push_value(type_var_tuple);
Expand Down
Loading
Loading