8000 remove to_owned() from typing · RustPython/RustPython@166c7bc · GitHub
[go: up one dir, main page]

Skip to content

Commit 166c7bc

Browse files
committed
remove to_owned() from typing
1 parent d6e04aa commit 166c7bc

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

vm/src/stdlib/typing.rs

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ pub(crate) mod decl {
346346
impl ParamSpec {
347347
#[pymethod(magic)]
348348
fn mro_entries(&self, _bases: PyObjectRef, vm: &VirtualMachine) -> PyResult {
349-
Err(vm.new_type_error("Cannot subclass an instance of ParamSpec".to_owned()))
349+
Err(vm.new_type_error("Cannot subclass an instance of ParamSpec"))
350350
}
351351

352352
#[pygetset(magic)]
@@ -483,16 +483,14 @@ pub(crate) mod decl {
483483
if let Some(name) = kwargs.swap_remove("name") {
484484
name
485485
} else {
486-
return Err(vm.new_type_error(
487-
"ParamSpec() missing required argument: 'name' (pos 1)".to_owned(),
488-
));
486+
return Err(
487+
vm.new_type_error("ParamSpec() missing required argument: 'name' (pos 1)")
488+
);
489489
}
490490
} else if args.args.len() == 1 {
491491
args.args[0].clone()
492492
} else {
493-
return Err(
494-
vm.new_type_error("ParamSpec() takes at most 1 positional argument".to_owned())
495-
);
493+
return Err(vm.new_type_error("ParamSpec() takes at most 1 positional argument"));
496494
};
497495

498496
let bound = kwargs.swap_remove("bound");
@@ -524,15 +522,11 @@ pub(crate) mod decl {
524522

525523
// Check for invalid combinations
526524
if covariant && contravariant {
527-
return Err(
528-
vm.new_value_error("Bivariant type variables are not supported.".to_owned())
529-
);
525+
return Err(vm.new_value_error("Bivariant type variables are not supported."));
530526
}
531527

532528
if infer_variance && (covariant || contravariant) {
533-
return Err(vm.new_value_error(
534-
"Variance cannot be specified with infer_variance".to_owned(),
535-
));
529+
return Err(vm.new_value_error("Variance cannot be specified with infer_variance"));
536530
}
537531

538532
// Handle default value
@@ -653,12 +647,12 @@ pub(crate) mod decl {
653647

654648
#[pymethod(magic)]
655649
fn mro_entries(&self, _bases: PyObjectRef, vm: &VirtualMachine) -> PyResult {
656-
Err(vm.new_type_error("Cannot subclass an instance of TypeVarTuple".to_owned()))
650+
Err(vm.new_type_error("Cannot subclass an instance of TypeVarTuple"))
657651
}
658652

659653
#[pymethod(magic)]
660654
fn typing_subst(&self, _arg: PyObjectRef, vm: &VirtualMachine) -> PyResult {
661-
Err(vm.new_type_error("Substitution of bare TypeVarTuple is not supported".to_owned()))
655+
Err(vm.new_type_error("Substitution of bare TypeVarTuple is not supported"))
662656
}
663657

664658
#[pymethod(magic)]
@@ -685,15 +679,13 @@ pub(crate) mod decl {
685679
name
686680
} else {
687681
return Err(vm.new_type_error(
688-
"TypeVarTuple() missing required argument: 'name' (pos 1)".to_owned(),
682+
"TypeVarTuple() missing required argument: 'name' (pos 1)",
689683
));
690684
}
691685
} else if args.args.len() == 1 {
692686
args.args[0].clone()
693687
} else {
694-
return Err(vm.new_type_error(
695-
"TypeVarTuple() takes at most 1 positional argument".to_owned(),
696-
));
688+
return Err(vm.new_type_error("TypeVarTuple() takes at most 1 positional argument"));
697689
};
698690

699691
let default = kwargs.swap_remove("default");
@@ -755,7 +747,7 @@ pub(crate) mod decl {
755747
impl ParamSpecArgs {
756748
#[pymethod(magic)]
757749
fn mro_entries(&self, _bases: PyObjectRef, vm: &VirtualMachine) -> PyResult {
758-
Err(vm.new_type_error("Cannot subclass an instance of ParamSpecArgs".to_owned()))
750+
Err(vm.new_type_error("Cannot subclass an instance of ParamSpecArgs"))
759751
}
760752

761753
#[pygetset(magic)]
@@ -834,7 +826,7 @@ pub(crate) mod decl {
834826
impl ParamSpecKwargs {
835827
#[pymethod(magic)]
836828
fn mro_entries(&self, _bases: PyObjectRef, vm: &VirtualMachine) -> PyResult {
837-
Err(vm.new_type_error("Cannot subclass an instance of ParamSpecKwargs".to_owned()))
829+
Err(vm.new_type_error("Cannot subclass an instance of ParamSpecKwargs"))
838830
}
839831

840832
#[pygetset(magic)]

0 commit comments

Comments
 (0)
0