Skip to content

Commit bb77ab2

Browse files
committed
ParamSpec.__repr__
1 parent b6ff541 commit bb77ab2

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)
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