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
Fix more repr
  • Loading branch information
youknowone committed Jun 30, 2025
commit 56403650bea6a68a905a5faec54cb5a786ec7462
8 changes: 0 additions & 8 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1436,8 +1436,6 @@ class G2(Generic[Unpack[Ts]]): pass
with self.assertRaises(TypeError):
C[int, Unpack[Ts], Unpack[Ts]]

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_repr_is_correct(self):
Ts = TypeVarTuple('Ts')

Expand Down Expand Up @@ -1555,8 +1553,6 @@ class A(Generic[Unpack[Ts]]): pass
self.assertEndsWith(repr(K[float]), 'A[float, typing.Unpack[typing.Tuple[str, ...]]]')
self.assertEndsWith(repr(K[float, str]), 'A[float, str, typing.Unpack[typing.Tuple[str, ...]]]')

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_cannot_subclass(self):
with self.assertRaisesRegex(TypeError, NOT_A_BASE_TYPE % 'TypeVarTuple'):
class C(TypeVarTuple): pass
Expand Down Expand Up @@ -3634,8 +3630,6 @@ def test_new_repr_complex(self):
'typing.List[typing.Tuple[typing.List[int], typing.List[int]]]'
)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_new_repr_bare(self):
T = TypeVar('T')
self.assertEqual(repr(Generic[T]), 'typing.Generic[~T]')
Expand Down Expand Up @@ -4300,8 +4294,6 @@ class Y(C[int]):
self.assertEqual(Y.__qualname__,
'GenericTests.test_repr_2.<locals>.Y')

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_repr_3(self):
T = TypeVar('T')
T1 = TypeVar('T1')
Expand Down
6 changes: 3 additions & 3 deletions vm/src/stdlib/typing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ pub(crate) mod decl {
#[inline(always)]
fn repr_str(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<String> {
let name = zelf.__name__().str(vm)?;
Ok(format!("~{}", name))
Ok(format!("~{name}"))
}
}

Expand Down Expand Up @@ -747,7 +747,7 @@ pub(crate) mod decl {
#[inline(always)]
fn repr_str(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<String> {
let name = zelf.name.str(vm)?;
Ok(format!("*{name}"))
Ok(name.to_string())
}
}

Expand Down Expand Up @@ -968,7 +968,7 @@ pub(crate) mod decl {
}

#[pyattr]
#[pyclass(name)]
#[pyclass(name = "Generic", module = "typing")]
#[derive(Debug, PyPayload)]
#[allow(dead_code)]
pub(crate) struct Generic {}
Expand Down
Loading