Merge pull request #2946 from youknowone/format

Trivial clean up
This commit is contained in:
Jim Fasarakis-Hilliard
2021-08-24 06:44:01 +03:00
committed by GitHub
5 changed files with 29 additions and 36 deletions

View File

@@ -121,7 +121,6 @@ impl Diagnostic {
}
}
#[allow(unconditional_recursion)]
pub fn panic(&self) -> ! {
match &self.inner {
Repr::Single { text, .. } => panic!("{}", text),

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

@@ -155,7 +155,6 @@ pub fn float_pow(v1: f64, v2: f64, vm: &VirtualMachine) -> PyResult {
}
#[pyimpl(flags(BASETYPE), with(Comparable, Hashable))]
#[allow(clippy::trivially_copy_pass_by_ref)]
impl PyFloat {
#[pyslot]
fn tp_new(
@@ -168,9 +167,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))
);
}
}

View File

@@ -1279,7 +1279,6 @@ impl ExecutingFrame<'_> {
Ok(None)
}
#[allow(clippy::collapsible_if)]
fn execute_build_map(
&mut self,
vm: &VirtualMachine,
@@ -1296,6 +1295,7 @@ impl ExecutingFrame<'_> {
vm.new_type_error(format!("'{}' object is not a mapping", obj.class().name))
})?;
for (key, value) in dict {
#[allow(clippy::collapsible_if)]
if for_call {
if map_obj.contains_key(key.clone(), vm) {
let key_repr = vm.to_repr(&key)?;