Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
typing.TypeVar
  • Loading branch information
youknowone committed Jun 24, 2025
commit 29e452a9b93da3b1b806ce2f4463f53d6a56a834
44 changes: 0 additions & 44 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ def test_alias(self):

class TypeVarTests(BaseTestCase):
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_basic_plain(self):
T = TypeVar('T')
# T equals itself.
Expand Down Expand Up @@ -405,7 +404,6 @@ def test_basic_with_exec(self):
self.assertIs(T.__module__, None)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_attributes(self):
T_bound = TypeVar('T_bound', bound=int)
self.assertEqual(T_bound.__name__, 'T_bound')
Expand Down Expand Up @@ -448,14 +446,11 @@ def test_typevar_subclass_type_error(self):
issubclass(T, int)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_constrained_error(self):
with self.assertRaises(TypeError):
X = TypeVar('X', int)
X

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_union_unique(self):
X = TypeVar('X')
Y = TypeVar('Y')
Expand Down Expand Up @@ -486,7 +481,6 @@ def test_union_constrained(self):
self.assertNotEqual(Union[A, str], Union[A])

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_repr(self):
self.assertEqual(repr(T), '~T')
self.assertEqual(repr(KT), '~KT')
Expand All @@ -502,7 +496,6 @@ def test_no_redefinition(self):
self.assertNotEqual(TypeVar('T', int, str), TypeVar('T', int, str))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_cannot_subclass(self):
with self.assertRaisesRegex(TypeError, NOT_A_BASE_TYPE % 'TypeVar'):
class V(TypeVar): pass
Expand All @@ -515,8 +508,6 @@ def test_cannot_instantiate_vars(self):
with self.assertRaises(TypeError):
TypeVar('A')()

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_bound_errors(self):
with self.assertRaises(TypeError):
TypeVar('X', bound=Union)
Expand All @@ -533,22 +524,16 @@ def test_missing__name__(self):
)
exec(code, {})

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_no_bivariant(self):
with self.assertRaises(ValueError):
TypeVar('T', covariant=True, contravariant=True)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_cannot_combine_explicit_and_infer(self):
with self.assertRaises(ValueError):
TypeVar('T', covariant=True, infer_variance=True)
with self.assertRaises(ValueError):
TypeVar('T', contravariant=True, infer_variance=True)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_var_substitution(self):
T = TypeVar('T')
subst = T.__typing_subst__
Expand Down Expand Up @@ -591,7 +576,6 @@ def test_many_weakrefs(self):
del vals

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_constructor(self):
T = TypeVar(name="T")
self.assertEqual(T.__name__, "T")
Expand Down Expand Up @@ -648,8 +632,6 @@ def test_constructor(self):
self.assertIs(T.__infer_variance__, True)

class TypeParameterDefaultsTests(BaseTestCase):
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_typevar(self):
T = TypeVar('T', default=int)
self.assertEqual(T.__default__, int)
Expand Down Expand Up @@ -844,8 +826,6 @@ class A(Generic[T, U, DefaultStrT]): ...
):
Test = A[int]

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_pickle(self):
global U, U_co, U_contra, U_default # pickle wants to reference the class by name
U = TypeVar('U')
Expand Down Expand Up @@ -3695,8 +3675,6 @@ def test_repr(self):
self.assertEqual(repr(MySimpleMapping),
f"<class '{__name__}.MySimpleMapping'>")

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_chain_repr(self):
T = TypeVar('T')
S = TypeVar('S')
Expand All @@ -3721,8 +3699,6 @@ class C(Generic[T]):
self.assertTrue(str(Z).endswith(
'.C[typing.Tuple[str, int]]'))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_new_repr(self):
T = TypeVar('T')
U = TypeVar('U', covariant=True)
Expand All @@ -3734,8 +3710,6 @@ def test_new_repr(self):
self.assertEqual(repr(List[S][T][int]), 'typing.List[int]')
self.assertEqual(repr(List[int]), 'typing.List[int]')

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_new_repr_complex(self):
T = TypeVar('T')
TS = TypeVar('TS')
Expand Down Expand Up @@ -3862,8 +3836,6 @@ def test_orig_bases(self):
class C(typing.Dict[str, T]): ...
self.assertEqual(C.__orig_bases__, (typing.Dict[str, T],))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_naive_runtime_checks(self):
def naive_dict_check(obj, tp):
# Check if a dictionary conforms to Dict type
Expand Down Expand Up @@ -3919,8 +3891,6 @@ class D(C, List[T][U][V]): ...
self.assertEqual(C.__orig_bases__, (List[T][U][V],))
self.assertEqual(D.__orig_bases__, (C, List[T][U][V]))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_subscript_meta(self):
T = TypeVar('T')
class Meta(type): ...
Expand Down Expand Up @@ -3972,8 +3942,6 @@ class A(Generic[T]):
self.assertTrue(repr(Tuple[mod_generics_cache.B.A[str]])
.endswith('mod_generics_cache.B.A[str]]'))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_extended_generic_rules_eq(self):
T = TypeVar('T')
U = TypeVar('U')
Expand All @@ -3990,8 +3958,6 @@ class Derived(Base): ...
self.assertEqual(Callable[[T], T][KT], Callable[[KT], KT])
self.assertEqual(Callable[..., List[T]][int], Callable[..., List[int]])

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_extended_generic_rules_repr(self):
T = TypeVar('T')
self.assertEqual(repr(Union[Tuple, Callable]).replace('typing.', ''),
Expand Down Expand Up @@ -4298,8 +4264,6 @@ class C(B[int]):
)
del PP

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_copy_and_deepcopy(self):
T = TypeVar('T')
class Node(Generic[T]): ...
Expand Down Expand Up @@ -8419,8 +8383,6 @@ def test_order_in_union(self):
with self.subTest(args=args):
self.assertEqual(expr2, Union[args])

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_specialize(self):
L = Annotated[List[T], "my decoration"]
LI = Annotated[List[int], "my decoration"]
Expand Down Expand Up @@ -8471,8 +8433,6 @@ def __eq__(self, other):
self.assertEqual(a.x, c.x)
self.assertEqual(a.classvar, c.classvar)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_instantiate_generic(self):
MyCount = Annotated[typing.Counter[T], "my decoration"]
self.assertEqual(MyCount([4, 4, 5]), {4: 2, 5: 1})
Expand Down Expand Up @@ -8601,8 +8561,6 @@ class _Annotated_test_G(Generic[T]):
self.assertEqual(x.bar, 'abc')
self.assertEqual(x.x, 1)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_subst(self):
dec = "a decoration"
dec2 = "another decoration"
Expand Down Expand Up @@ -8748,8 +8706,6 @@ def test_typevar_subst(self):
with self.assertRaises(TypeError):
J[int]

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_annotated_in_other_types(self):
X = List[Annotated[T, 5]]
self.assertEqual(X[int], List[Annotated[int, 5]])
Expand Down
2 changes: 1 addition & 1 deletion vm/src/builtins/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ fn best_base<'a>(bases: &'a [PyTypeRef], vm: &VirtualMachine) -> PyResult<&'a Py
if !base_i.slots.flags.has_feature(PyTypeFlags::BASETYPE) {
return Err(vm.new_type_error(format!(
"type '{}' is not an acceptable base type",
base_i.name()
base_i.slot_name()
)));
}

Expand Down
Loading
Loading