Skip to content

Commit 5640365

Browse files
committed
Fix more repr
1 parent bb77ab2 commit 5640365

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

Lib/test/test_typing.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,8 +1436,6 @@ class G2(Generic[Unpack[Ts]]): pass
14361436
with self.assertRaises(TypeError):
14371437
C[int, Unpack[Ts], Unpack[Ts]]
14381438

1439-
# TODO: RUSTPYTHON
1440-
@unittest.expectedFailure
14411439
def test_repr_is_correct(self):
14421440
Ts = TypeVarTuple('Ts')
14431441

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

1558-
# TODO: RUSTPYTHON
1559-
@unittest.expectedFailure
15601556
def test_cannot_subclass(self):
15611557
with self.assertRaisesRegex(TypeError, NOT_A_BASE_TYPE % 'TypeVarTuple'):
15621558
class C(TypeVarTuple): pass
@@ -3634,8 +3630,6 @@ def test_new_repr_complex(self):
36343630
'typing.List[typing.Tuple[typing.List[int], typing.List[int]]]'
36353631
)
36363632

3637-
# TODO: RUSTPYTHON
3638-
@unittest.expectedFailure
36393633
def test_new_repr_bare(self):
36403634
T = TypeVar('T')
36413635
self.assertEqual(repr(Generic[T]), 'typing.Generic[~T]')
@@ -4300,8 +4294,6 @@ class Y(C[int]):
43004294
self.assertEqual(Y.__qualname__,
43014295
'GenericTests.test_repr_2.<locals>.Y')
43024296

4303-
# TODO: RUSTPYTHON
4304-
@unittest.expectedFailure
43054297
def test_repr_3(self):
43064298
T = TypeVar('T')
43074299
T1 = TypeVar('T1')

vm/src/stdlib/typing.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ pub(crate) mod decl {
559559
#[inline(always)]
560560
fn repr_str(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<String> {
561561
let name = zelf.__name__().str(vm)?;
562-
Ok(format!("~{}", name))
562+
Ok(format!("~{name}"))
563563
}
564564
}
565565

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

@@ -968,7 +968,7 @@ pub(crate) mod decl {
968968
}
969969

970970
#[pyattr]
971-
#[pyclass(name)]
971+
#[pyclass(name = "Generic", module = "typing")]
972972
#[derive(Debug, PyPayload)]
973973
#[allow(dead_code)]
974974
pub(crate) struct Generic {}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy