forked from Rust-related/RustPython
fix clippy warnings
This commit is contained in:
@@ -312,7 +312,7 @@ impl Repr<'_> {
|
||||
repr.write_str(s)?;
|
||||
} else {
|
||||
for ch in s.chars() {
|
||||
let res = match ch {
|
||||
match ch {
|
||||
'\n' => repr.write_str("\\n"),
|
||||
'\t' => repr.write_str("\\t"),
|
||||
'\r' => repr.write_str("\\r"),
|
||||
@@ -338,8 +338,7 @@ impl Repr<'_> {
|
||||
_ => {
|
||||
write!(repr, "\\U{:08x}", ch as u32)
|
||||
}
|
||||
};
|
||||
let () = res?;
|
||||
}?;
|
||||
}
|
||||
}
|
||||
repr.write_char(quote)
|
||||
|
||||
@@ -734,7 +734,7 @@ impl PyStr {
|
||||
let s = self.as_str();
|
||||
!s.is_empty()
|
||||
&& s.chars()
|
||||
.filter(|c| !c.is_digit(10))
|
||||
.filter(|c| !c.is_ascii_digit())
|
||||
.all(|c| valid_unicodes.contains(&(c as u16)))
|
||||
}
|
||||
|
||||
|
||||
@@ -307,7 +307,11 @@ impl PyBytesInner {
|
||||
}
|
||||
|
||||
pub fn isdigit(&self) -> bool {
|
||||
!self.elements.is_empty() && self.elements.iter().all(|x| char::from(*x).is_digit(10))
|
||||
!self.elements.is_empty()
|
||||
&& self
|
||||
.elements
|
||||
.iter()
|
||||
.all(|x| char::from(*x).is_ascii_digit())
|
||||
}
|
||||
|
||||
pub fn islower(&self) -> bool {
|
||||
|
||||
@@ -120,7 +120,7 @@ pub(crate) struct FormatSpec {
|
||||
|
||||
pub(crate) fn get_num_digits(text: &str) -> usize {
|
||||
for (index, character) in text.char_indices() {
|
||||
if !character.is_digit(10) {
|
||||
if !character.is_ascii_digit() {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -920,7 +920,7 @@ pub fn make_module(vm: &VirtualMachine, module: PyObjectRef) {
|
||||
|
||||
crate::protocol::VecBuffer::make_class(&vm.ctx);
|
||||
|
||||
let _ = builtins::extend_module(vm, &module);
|
||||
builtins::extend_module(vm, &module);
|
||||
|
||||
let debug_mode: bool = vm.state.settings.optimize == 0;
|
||||
extend_module!(vm, module, {
|
||||
|
||||
@@ -1280,7 +1280,7 @@ mod _io {
|
||||
}
|
||||
}
|
||||
if self.writable() {
|
||||
let _ = self.flush_rewind(vm)?;
|
||||
self.flush_rewind(vm)?;
|
||||
}
|
||||
self.reset_read();
|
||||
self.pos = 0;
|
||||
|
||||
@@ -316,7 +316,8 @@ mod decl {
|
||||
fn repr(&self, vm: &VirtualMachine) -> PyResult<String> {
|
||||
let mut fmt = format!("{}", &self.object.repr(vm)?);
|
||||
if let Some(ref times) = self.times {
|
||||
fmt.push_str(&format!(", {}", times.read()));
|
||||
fmt.push_str(", ");
|
||||
fmt.push_str(×.read().to_string());
|
||||
}
|
||||
Ok(format!("repeat({})", fmt))
|
||||
}
|
||||
|
||||
@@ -1763,7 +1763,7 @@ pub(crate) struct SupportFunc {
|
||||
follow_symlinks: Option<bool>,
|
||||
}
|
||||
|
||||
impl<'a> SupportFunc {
|
||||
impl SupportFunc {
|
||||
pub(crate) fn new(
|
||||
name: &'static str,
|
||||
fd: Option<bool>,
|
||||
|
||||
@@ -516,8 +516,7 @@ pub mod module {
|
||||
|
||||
#[pyfunction]
|
||||
fn sched_yield(vm: &VirtualMachine) -> PyResult<()> {
|
||||
let _ = nix::sched::sched_yield().map_err(|e| e.to_pyexception(vm))?;
|
||||
Ok(())
|
||||
nix::sched::sched_yield().map_err(|e| e.to_pyexception(vm))
|
||||
}
|
||||
|
||||
#[pyattr]
|
||||
|
||||
@@ -71,7 +71,7 @@ impl Interpreter {
|
||||
.map_err(|exc| vm.handle_exit_exception(exc))
|
||||
.unwrap_or_else(|code| code);
|
||||
|
||||
let _ = atexit::_run_exitfuncs(vm);
|
||||
atexit::_run_exitfuncs(vm);
|
||||
|
||||
flush_std(vm);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user