Skip to content

Commit fd52673

Browse files
committed
ParamSpec.__repr__
1 parent 6b697d1 commit fd52673

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

vm/src/stdlib/typing.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ pub(crate) mod decl {
343343
infer_variance: bool,
344344
}
345345

346-
#[pyclass(flags(HAS_DICT), with(AsNumber, Constructor))]
346+
#[pyclass(flags(HAS_DICT), with(AsNumber, Constructor, Representable))]
347347
impl ParamSpec {
348348
#[pymethod]
349349
fn __mro_entries__(&self, _bases: PyObjectRef, vm: &VirtualMachine) -> PyResult {
@@ -555,6 +555,14 @@ pub(crate) mod decl {
555555
}
556556
}
557557

558+
impl Representable for ParamSpec {
559+
#[inline(always)]
560+
fn repr_str(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<String> {
561+
let name = zelf.__name__().str(vm)?;
562+
Ok(format!("~{}", name))
563+
}
564+
}
565+
558566
pub(crate) fn make_paramspec(name: PyObjectRef) -> ParamSpec {
559567
ParamSpec {
560568
name,

0 commit comments

Comments
 (0)