reduce too deep indent depth

This commit is contained in:
Jeong YunWon
2021-08-24 02:52:33 +09:00
parent 1fe71aa2a1
commit f4e863927d
3 changed files with 28 additions and 33 deletions

View File

@@ -200,25 +200,24 @@ pub trait AnyStr<'s>: 's {
F: Fn(&Self, &T) -> bool,
{
let (affix, range) = args.get_value(self.bytes_len());
if range.is_normal() {
let value = self.get_bytes(range);
single_or_tuple_any(
affix,
&|s: &T| Ok(func(value, s)),
&|o| {
format!(
"{} first arg must be {} or a tuple of {}, not {}",
func_name,
py_type_name,
py_type_name,
o.class(),
)
},
vm,
)
} else {
Ok(false)
if !range.is_normal() {
return Ok(false);
}
let value = self.get_bytes(range);
single_or_tuple_any(
affix,
&|s: &T| Ok(func(value, s)),
&|o| {
format!(
"{} first arg must be {} or a tuple of {}, not {}",
func_name,
py_type_name,
py_type_name,
o.class(),
)
},
vm,
)
}
#[inline]

View File

@@ -171,9 +171,7 @@ impl PyFloat {
OptionalArg::Present(val) => {
let val = if cls.is(&vm.ctx.types.float_type) {
match val.downcast_exact::<PyFloat>(vm) {
Ok(f) => {
return Ok(f);
}
Ok(f) => return Ok(f),
Err(val) => val,
}
} else {

View File

@@ -218,21 +218,19 @@ impl PyFunction {
.zip(&*code.varnames)
.skip(code.arg_count)
.take(code.kwonlyarg_count)
.filter(|(slot, _)| slot.is_none())
{
if slot.is_none() {
if let Some(defaults) = &get_defaults!().1 {
if let Some(default) = defaults.get_item_option(kwarg.clone(), vm)? {
*slot = Some(default);
continue;
}
if let Some(defaults) = &get_defaults!().1 {
if let Some(default) = defaults.get_item_option(kwarg.clone(), vm)? {
*slot = Some(default);
continue;
}
// No default value and not specified.
return Err(vm.new_type_error(format!(
"Missing required kw only argument: '{}'",
kwarg
)));
}
// No default value and not specified.
return Err(
vm.new_type_error(format!("Missing required kw only argument: '{}'", kwarg))
);
}
}