From b35861005eb2d7828958427e606fa16a88d80d45 Mon Sep 17 00:00:00 2001 From: Jeong YunWon <69878+youknowone@users.noreply.github.com> Date: Fri, 17 Mar 2023 14:02:24 +0900 Subject: [PATCH] more cspell (#4702) --- .cspell.json | 64 ++++++++++++++++++++++++++++++++- stdlib/src/array.rs | 2 ++ stdlib/src/binascii.rs | 2 ++ stdlib/src/bz2.rs | 2 ++ stdlib/src/hashlib.rs | 2 ++ stdlib/src/syslog.rs | 2 ++ stdlib/src/unicodedata.rs | 3 ++ stdlib/src/zlib.rs | 2 ++ vm/src/anystr.rs | 4 +-- vm/src/builtins/float.rs | 2 ++ vm/src/builtins/genericalias.rs | 6 ++-- vm/src/builtins/range.rs | 18 +++++----- vm/src/builtins/slice.rs | 1 + vm/src/builtins/str.rs | 32 ++++++++--------- vm/src/builtins/super.rs | 6 ++-- vm/src/builtins/tuple.rs | 16 ++++----- vm/src/builtins/union.rs | 8 ++--- vm/src/bytesinner.rs | 16 ++++----- 18 files changed, 134 insertions(+), 54 deletions(-) diff --git a/.cspell.json b/.cspell.json index 581666910..276869671 100644 --- a/.cspell.json +++ b/.cspell.json @@ -26,11 +26,17 @@ "words": [ // Rust "ahash", + "bidi", + "biguint", "bindgen", "bitflags", + "bstr", + "byteorder", "chrono", + "consts", "cstring", "flate2", + "fract", "hasher", "idents", "indexmap", @@ -38,38 +44,67 @@ "keccak", "lalrpop", "libc", + "libz", + "longlong", "Manually", "maplit", "memmap", "metas", + "modpow", + "nanos", "peekable", + "powc", + "powf", "prepended", "punct", + "replacen", + "rsplitn", "rustc", "rustfmt", "splitn", + "subsec", + "timsort", "trai", + "ulonglong", "unic", "unistd", + "winapi", + "winsock", // Python "abstractmethods", "aiter", "anext", + "arrayiterator", + "arraytype", + "asend", + "athrow", "basicsize", "cformat", "classcell", + "closesocket", "codepoint", + "codepoints", "cpython", + "decompressor", "defaultaction", "descr", "dictcomp", + "dictitems", + "dictkeys", + "dictview", "docstring", "docstrings", "dunder", "eventmask", "fdel", + "fget", "fileencoding", + "fillchar", "finallyhandler", + "frombytes", + "fromhex", + "fromunicode", + "fset", "fspath", "fstring", "fstrings", @@ -79,12 +114,17 @@ "getnewargs", "getweakrefcount", "getweakrefs", + "hostnames", "idiv", "impls", + "infj", "instancecheck", "instanceof", + "isabstractmethod", + "itemiterator", "itemsize", "iternext", + "keyiterator", "kwarg", "kwargs", "linearization", @@ -92,13 +132,20 @@ "listcomp", "mappingproxy", "maxsplit", - "MemoryView", + "memoryview", + "memoryviewiterator", "metaclass", "metaclasses", "metatype", + "mro", + "mros", + "nanj", + "ndigits", "ndim", "nonbytes", "origname", + "posixsubprocess", + "pyexpat", "PYTHONDEBUG", "PYTHONHOME", "PYTHONINSPECT", @@ -108,7 +155,19 @@ "PYTHONVERBOSE", "PYTHONWARNINGS", "qualname", + "radd", "rdiv", + "rdivmod", + "reconstructor", + "reversevalueiterator", + "rfloordiv", + "rlshift", + "rmod", + "rpow", + "rrshift", + "rsub", + "rtruediv", + "scproxy", "setattro", "setcomp", "stacklevel", @@ -116,6 +175,7 @@ "subclasshook", "unionable", "unraisablehook", + "valueiterator", "vararg", "varargs", "varnames", @@ -165,6 +225,7 @@ "pystruct", "pystructseq", "pytrace", + "reducelib", "richcompare", "RustPython", "struc", @@ -215,6 +276,7 @@ "unparser", "VARKEYWORDS", "varkwarg", + "wbits", "withitem", "withs" ], diff --git a/stdlib/src/array.rs b/stdlib/src/array.rs index c1c58c4e0..b9481eaba 100644 --- a/stdlib/src/array.rs +++ b/stdlib/src/array.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore typecode tofile tolist fromfile + use rustpython_vm::{PyObjectRef, VirtualMachine}; pub(crate) fn make_module(vm: &VirtualMachine) -> PyObjectRef { diff --git a/stdlib/src/binascii.rs b/stdlib/src/binascii.rs index 2dca65deb..d7467fc8a 100644 --- a/stdlib/src/binascii.rs +++ b/stdlib/src/binascii.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore hexlify unhexlify uuencodes + pub(super) use decl::crc32; pub(crate) use decl::make_module; use rustpython_vm::{builtins::PyBaseExceptionRef, convert::ToPyException, VirtualMachine}; diff --git a/stdlib/src/bz2.rs b/stdlib/src/bz2.rs index f68194e3a..f150b06eb 100644 --- a/stdlib/src/bz2.rs +++ b/stdlib/src/bz2.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore compresslevel + pub(crate) use _bz2::make_module; #[pymodule] diff --git a/stdlib/src/hashlib.rs b/stdlib/src/hashlib.rs index 575197433..f3ddb0091 100644 --- a/stdlib/src/hashlib.rs +++ b/stdlib/src/hashlib.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore usedforsecurity HASHXOF + pub(crate) use hashlib::make_module; #[pymodule] diff --git a/stdlib/src/syslog.rs b/stdlib/src/syslog.rs index d32ec7cfd..bb013c925 100644 --- a/stdlib/src/syslog.rs +++ b/stdlib/src/syslog.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore logoption openlog setlogmask upto + pub(crate) use syslog::make_module; #[pymodule(name = "syslog")] diff --git a/stdlib/src/unicodedata.rs b/stdlib/src/unicodedata.rs index 719d63c67..c8332740b 100644 --- a/stdlib/src/unicodedata.rs +++ b/stdlib/src/unicodedata.rs @@ -1,6 +1,9 @@ /* Access to the unicode database. See also: https://docs.python.org/3/library/unicodedata.html */ + +// spell-checker:ignore nfkc unistr unidata + use crate::vm::{ builtins::PyStr, convert::TryFromBorrowedObject, PyObject, PyObjectRef, PyPayload, PyResult, VirtualMachine, diff --git a/stdlib/src/zlib.rs b/stdlib/src/zlib.rs index 7f3d4d919..ceb9c95cd 100644 --- a/stdlib/src/zlib.rs +++ b/stdlib/src/zlib.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore compressobj decompressobj zdict chunksize zlibmodule miniz + pub(crate) use zlib::make_module; #[pymodule] diff --git a/vm/src/anystr.rs b/vm/src/anystr.rs index 1f1077f5c..1becc7d71 100644 --- a/vm/src/anystr.rs +++ b/vm/src/anystr.rs @@ -194,7 +194,7 @@ pub trait AnyStr { SW: Fn(&Self, isize, &VirtualMachine) -> Vec, { let (sep, maxsplit) = args.get_value(vm)?; - let splited = if let Some(pattern) = sep { + let splits = if let Some(pattern) = sep { if maxsplit < 0 { split(self, pattern.as_ref(), vm) } else { @@ -203,7 +203,7 @@ pub trait AnyStr { } else { splitw(self, maxsplit, vm) }; - Ok(splited) + Ok(splits) } fn py_split_whitespace(&self, maxsplit: isize, convert: F) -> Vec where diff --git a/vm/src/builtins/float.rs b/vm/src/builtins/float.rs index d97cb4024..6f0b5fda6 100644 --- a/vm/src/builtins/float.rs +++ b/vm/src/builtins/float.rs @@ -1,3 +1,5 @@ +// spell-checker:ignore numer denom + use super::{ try_bigint_to_f64, PyByteArray, PyBytes, PyInt, PyIntRef, PyStr, PyStrRef, PyType, PyTypeRef, }; diff --git a/vm/src/builtins/genericalias.rs b/vm/src/builtins/genericalias.rs index 5214de37f..eff834132 100644 --- a/vm/src/builtins/genericalias.rs +++ b/vm/src/builtins/genericalias.rs @@ -225,9 +225,9 @@ fn make_parameters(args: &PyTupleRef, vm: &VirtualMachine) -> PyTupleRef { .get_attr(identifier!(vm, __parameters__), vm) .and_then(|obj| PyTupleRef::try_from_object(vm, obj)) { - for subparam in &subparams { - if !parameters.iter().any(|param| param.is(subparam)) { - parameters.push(subparam.clone()); + for sub_param in &subparams { + if !parameters.iter().any(|param| param.is(sub_param)) { + parameters.push(sub_param.clone()); } } } diff --git a/vm/src/builtins/range.rs b/vm/src/builtins/range.rs index 91136a3b2..2d214174f 100644 --- a/vm/src/builtins/range.rs +++ b/vm/src/builtins/range.rs @@ -345,19 +345,19 @@ impl PyRange { fn getitem(&self, subscript: PyObjectRef, vm: &VirtualMachine) -> PyResult { match RangeIndex::try_from_object(vm, subscript)? { RangeIndex::Slice(slice) => { - let (mut substart, mut substop, mut substep) = + let (mut sub_start, mut sub_stop, mut sub_step) = slice.inner_indices(&self.compute_length(), vm)?; let range_step = &self.step; let range_start = &self.start; - substep *= range_step.as_bigint(); - substart = (substart * range_step.as_bigint()) + range_start.as_bigint(); - substop = (substop * range_step.as_bigint()) + range_start.as_bigint(); + sub_step *= range_step.as_bigint(); + sub_start = (sub_start * range_step.as_bigint()) + range_start.as_bigint(); + sub_stop = (sub_stop * range_step.as_bigint()) + range_start.as_bigint(); Ok(PyRange { - start: vm.new_pyref(substart), - stop: vm.new_pyref(substop), - step: vm.new_pyref(substep), + start: vm.new_pyref(sub_start), + stop: vm.new_pyref(sub_stop), + step: vm.new_pyref(sub_step), } .into_ref(vm) .into()) @@ -582,8 +582,8 @@ impl IterNext for PyLongRangeIterator { } } -// When start, stop, step are isizes, we can use a faster more compact representation -// that only operates using isizes to track values. +// When start, stop, step are isize, we can use a faster more compact representation +// that only operates using isize to track values. #[pyclass(module = false, name = "range_iterator")] #[derive(Debug)] pub struct PyRangeIterator { diff --git a/vm/src/builtins/slice.rs b/vm/src/builtins/slice.rs index e6e78612c..5177a0bb4 100644 --- a/vm/src/builtins/slice.rs +++ b/vm/src/builtins/slice.rs @@ -1,4 +1,5 @@ // sliceobject.{h,c} in CPython +// spell-checker:ignore sliceobject use super::{PyTupleRef, PyType, PyTypeRef}; use crate::{ class::PyClassImpl, diff --git a/vm/src/builtins/str.rs b/vm/src/builtins/str.rs index 8447891da..a2f85479e 100644 --- a/vm/src/builtins/str.rs +++ b/vm/src/builtins/str.rs @@ -693,9 +693,9 @@ impl PyStr { /// If the string ends with the suffix string, return string[:len(suffix)] /// Otherwise, return a copy of the original string. #[pymethod] - fn removesuffix(&self, suff: PyStrRef) -> String { + fn removesuffix(&self, suffix: PyStrRef) -> String { self.as_str() - .py_removesuffix(suff.as_str(), suff.byte_len(), |s, p| s.ends_with(p)) + .py_removesuffix(suffix.as_str(), suffix.byte_len(), |s, p| s.ends_with(p)) .to_owned() } @@ -711,15 +711,15 @@ impl PyStr { #[pymethod] fn isdigit(&self) -> bool { - // python's isdigit also checks if exponents are digits, these are the unicodes for exponents - let valid_unicodes: [u16; 10] = [ + // python's isdigit also checks if exponents are digits, these are the unicode codepoints for exponents + let valid_codepoints: [u16; 10] = [ 0x2070, 0x00B9, 0x00B2, 0x00B3, 0x2074, 0x2075, 0x2076, 0x2077, 0x2078, 0x2079, ]; let s = self.as_str(); !s.is_empty() && s.chars() .filter(|c| !c.is_ascii_digit()) - .all(|c| valid_unicodes.contains(&(c as u16))) + .all(|c| valid_codepoints.contains(&(c as u16))) } #[pymethod] @@ -827,12 +827,12 @@ impl PyStr { fn replace(&self, old: PyStrRef, new: PyStrRef, count: OptionalArg) -> String { let s = self.as_str(); match count { - OptionalArg::Present(maxcount) if maxcount >= 0 => { - if maxcount == 0 || s.is_empty() { + OptionalArg::Present(max_count) if max_count >= 0 => { + if max_count == 0 || s.is_empty() { // nothing to do; return the original bytes s.into() } else { - s.replacen(old.as_str(), new.as_str(), maxcount as usize) + s.replacen(old.as_str(), new.as_str(), max_count as usize) } } _ => s.replace(old.as_str(), new.as_str()), @@ -1692,7 +1692,7 @@ impl AnyStr for str { F: Fn(&Self) -> PyObjectRef, { // CPython split_whitespace - let mut splited = Vec::new(); + let mut splits = Vec::new(); let mut last_offset = 0; let mut count = maxsplit; for (offset, _) in self.match_indices(|c: char| c.is_ascii_whitespace() || c == '\x0b') { @@ -1703,14 +1703,14 @@ impl AnyStr for str { if count == 0 { break; } - splited.push(convert(&self[last_offset..offset])); + splits.push(convert(&self[last_offset..offset])); last_offset = offset + 1; count -= 1; } if last_offset != self.len() { - splited.push(convert(&self[last_offset..])); + splits.push(convert(&self[last_offset..])); } - splited + splits } fn py_rsplit_whitespace(&self, maxsplit: isize, convert: F) -> Vec @@ -1718,7 +1718,7 @@ impl AnyStr for str { F: Fn(&Self) -> PyObjectRef, { // CPython rsplit_whitespace - let mut splited = Vec::new(); + let mut splits = Vec::new(); let mut last_offset = self.len(); let mut count = maxsplit; for (offset, _) in self.rmatch_indices(|c: char| c.is_ascii_whitespace() || c == '\x0b') { @@ -1729,14 +1729,14 @@ impl AnyStr for str { if count == 0 { break; } - splited.push(convert(&self[offset + 1..last_offset])); + splits.push(convert(&self[offset + 1..last_offset])); last_offset = offset; count -= 1; } if last_offset != 0 { - splited.push(convert(&self[..last_offset])); + splits.push(convert(&self[..last_offset])); } - splited + splits } } diff --git a/vm/src/builtins/super.rs b/vm/src/builtins/super.rs index dd68b5c3c..e5ca71eba 100644 --- a/vm/src/builtins/super.rs +++ b/vm/src/builtins/super.rs @@ -126,10 +126,10 @@ impl PySuper { #[pymethod(magic)] fn repr(&self) -> String { - let typname = &self.typ.name(); + let name = &self.typ.name(); match self.obj { - Some((_, ref ty)) => format!(", <{} object>>", typname, ty.name()), - None => format!(", NULL>"), + Some((_, ref ty)) => format!(", <{} object>>", name, ty.name()), + None => format!(", NULL>"), } } } diff --git a/vm/src/builtins/tuple.rs b/vm/src/builtins/tuple.rs index 382a826a6..6ae9377e0 100644 --- a/vm/src/builtins/tuple.rs +++ b/vm/src/builtins/tuple.rs @@ -56,7 +56,7 @@ impl IntoPyTuple for Vec { } } -macro_rules! impl_intopyobj_tuple { +macro_rules! impl_into_pyobj_tuple { ($(($T:ident, $idx:tt)),+) => { impl<$($T: ToPyObject),*> IntoPyTuple for ($($T,)*) { fn into_pytuple(self, vm: &VirtualMachine) -> PyTupleRef { @@ -72,13 +72,13 @@ macro_rules! impl_intopyobj_tuple { }; } -impl_intopyobj_tuple!((A, 0)); -impl_intopyobj_tuple!((A, 0), (B, 1)); -impl_intopyobj_tuple!((A, 0), (B, 1), (C, 2)); -impl_intopyobj_tuple!((A, 0), (B, 1), (C, 2), (D, 3)); -impl_intopyobj_tuple!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4)); -impl_intopyobj_tuple!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5)); -impl_intopyobj_tuple!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6)); +impl_into_pyobj_tuple!((A, 0)); +impl_into_pyobj_tuple!((A, 0), (B, 1)); +impl_into_pyobj_tuple!((A, 0), (B, 1), (C, 2)); +impl_into_pyobj_tuple!((A, 0), (B, 1), (C, 2), (D, 3)); +impl_into_pyobj_tuple!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4)); +impl_into_pyobj_tuple!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5)); +impl_into_pyobj_tuple!((A, 0), (B, 1), (C, 2), (D, 3), (E, 4), (F, 5), (G, 6)); impl PyTuple { pub(crate) fn fast_getitem(&self, idx: usize) -> PyObjectRef { diff --git a/vm/src/builtins/union.rs b/vm/src/builtins/union.rs index a5c11d3d2..09785a712 100644 --- a/vm/src/builtins/union.rs +++ b/vm/src/builtins/union.rs @@ -151,14 +151,14 @@ fn make_parameters(args: &PyTupleRef, vm: &VirtualMachine) -> PyTupleRef { if !parameters.iter().any(|param| param.is(arg)) { parameters.push(arg.clone()); } - } else if let Ok(subparams) = arg + } else if let Ok(sub_params) = arg .clone() .get_attr(identifier!(vm, __parameters__), vm) .and_then(|obj| PyTupleRef::try_from_object(vm, obj)) { - for subparam in &subparams { - if !parameters.iter().any(|param| param.is(subparam)) { - parameters.push(subparam.clone()); + for sub_param in &sub_params { + if !parameters.iter().any(|param| param.is(sub_param)) { + parameters.push(sub_param.clone()); } } } diff --git a/vm/src/bytesinner.rs b/vm/src/bytesinner.rs index fce0522a4..cf282be29 100644 --- a/vm/src/bytesinner.rs +++ b/vm/src/bytesinner.rs @@ -1044,7 +1044,7 @@ impl AnyStr for [u8] { where F: Fn(&Self) -> PyObjectRef, { - let mut splited = Vec::new(); + let mut splits = Vec::new(); let mut count = maxsplit; let mut haystack = self; while let Some(offset) = haystack.find_byteset(ASCII_WHITESPACES) { @@ -1052,22 +1052,22 @@ impl AnyStr for [u8] { if count == 0 { break; } - splited.push(convert(&haystack[..offset])); + splits.push(convert(&haystack[..offset])); count -= 1; } haystack = &haystack[offset + 1..]; } if !haystack.is_empty() { - splited.push(convert(haystack)); + splits.push(convert(haystack)); } - splited + splits } fn py_rsplit_whitespace(&self, maxsplit: isize, convert: F) -> Vec where F: Fn(&Self) -> PyObjectRef, { - let mut splited = Vec::new(); + let mut splits = Vec::new(); let mut count = maxsplit; let mut haystack = self; while let Some(offset) = haystack.rfind_byteset(ASCII_WHITESPACES) { @@ -1075,15 +1075,15 @@ impl AnyStr for [u8] { if count == 0 { break; } - splited.push(convert(&haystack[offset + 1..])); + splits.push(convert(&haystack[offset + 1..])); count -= 1; } haystack = &haystack[..offset]; } if !haystack.is_empty() { - splited.push(convert(haystack)); + splits.push(convert(haystack)); } - splited + splits } }