Skip to content

Commit fe13f80

Browse files
committed
cargo fmt
1 parent 728401d commit fe13f80

File tree

13 files changed

+31
-118
lines changed

13 files changed

+31
-118
lines changed

common/src/format.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,7 @@ impl FormatSpec {
412412
let magnitude_len = magnitude_str.len();
413413
let width = self.width.unwrap_or(magnitude_len) as i32 - prefix.len() as i32;
414414
let disp_digit_cnt = cmp::max(width, magnitude_len as i32);
415-
Self::add_magnitude_separators_for_char(
416-
magnitude_str,
417-
inter,
418-
sep,
419-
disp_digit_cnt,
420-
)
415+
Self::add_magnitude_separators_for_char(magnitude_str, inter, sep, disp_digit_cnt)
421416
}
422417
None => magnitude_str,
423418
}
@@ -657,8 +652,7 @@ impl FormatSpec {
657652
FormatAlign::Center => {
658653
let left_fill_chars_needed = fill_chars_needed / 2;
659654
let right_fill_chars_needed = fill_chars_needed - left_fill_chars_needed;
660-
let left_fill_string =
661-
Self::compute_fill_string(fill_char, left_fill_chars_needed);
655+
let left_fill_string = Self::compute_fill_string(fill_char, left_fill_chars_needed);
662656
let right_fill_string =
663657
Self::compute_fill_string(fill_char, right_fill_chars_needed);
664658
format!("{left_fill_string}{sign_str}{magnitude_str}{right_fill_string}")

vm/src/builtins/bytearray.rs

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -335,29 +335,17 @@ impl PyByteArray {
335335
}
336336

337337
#[pymethod]
338-
fn center(
339-
&self,
340-
options: ByteInnerPaddingOptions,
341-
vm: &VirtualMachine,
342-
) -> PyResult<Self> {
338+
fn center(&self, options: ByteInnerPaddingOptions, vm: &VirtualMachine) -> PyResult<Self> {
343339
Ok(self.inner().center(options, vm)?.into())
344340
}
345341

346342
#[pymethod]
347-
fn ljust(
348-
&self,
349-
options: ByteInnerPaddingOptions,
350-
vm: &VirtualMachine,
351-
) -> PyResult<Self> {
343+
fn ljust(&self, options: ByteInnerPaddingOptions, vm: &VirtualMachine) -> PyResult<Self> {
352344
Ok(self.inner().ljust(options, vm)?.into())
353345
}
354346

355347
#[pymethod]
356-
fn rjust(
357-
&self,
358-
options: ByteInnerPaddingOptions,
359-
vm: &VirtualMachine,
360-
) -> PyResult<Self> {
348+
fn rjust(&self, options: ByteInnerPaddingOptions, vm: &VirtualMachine) -> PyResult<Self> {
361349
Ok(self.inner().rjust(options, vm)?.into())
362350
}
363351

@@ -434,11 +422,7 @@ impl PyByteArray {
434422
}
435423

436424
#[pymethod]
437-
fn translate(
438-
&self,
439-
options: ByteInnerTranslateOptions,
440-
vm: &VirtualMachine,
441-
) -> PyResult<Self> {
425+
fn translate(&self, options: ByteInnerTranslateOptions, vm: &VirtualMachine) -> PyResult<Self> {
442426
Ok(self.inner().translate(options, vm)?.into())
443427
}
444428

@@ -663,11 +647,7 @@ impl Py<PyByteArray> {
663647
#[pyclass]
664648
impl PyRef<PyByteArray> {
665649
#[pymethod]
666-
fn lstrip(
667-
self,
668-
chars: OptionalOption<PyBytesInner>,
669-
vm: &VirtualMachine,
670-
) -> Self {
650+
fn lstrip(self, chars: OptionalOption<PyBytesInner>, vm: &VirtualMachine) -> Self {
671651
let inner = self.inner();
672652
let stripped = inner.lstrip(chars);
673653
let elements = &inner.elements;
@@ -680,11 +660,7 @@ impl PyRef<PyByteArray> {
680660
}
681661

682662
#[pymethod]
683-
fn rstrip(
684-
self,
685-
chars: OptionalOption<PyBytesInner>,
686-
vm: &VirtualMachine,
687-
) -> Self {
663+
fn rstrip(self, chars: OptionalOption<PyBytesInner>, vm: &VirtualMachine) -> Self {
688664
let inner = self.inner();
689665
let stripped = inner.rstrip(chars);
690666
let elements = &inner.elements;

vm/src/builtins/bytes.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,7 @@ impl PyBytes {
355355
}
356356

357357
#[pymethod]
358-
fn translate(
359-
&self,
360-
options: ByteInnerTranslateOptions,
361-
vm: &VirtualMachine,
362-
) -> PyResult<Self> {
358+
fn translate(&self, options: ByteInnerTranslateOptions, vm: &VirtualMachine) -> PyResult<Self> {
363359
Ok(self.inner.translate(options, vm)?.into())
364360
}
365361

vm/src/builtins/list.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,7 @@ impl Constructor for PyList {
379379
type Args = FuncArgs;
380380

381381
fn py_new(cls: PyTypeRef, _args: FuncArgs, vm: &VirtualMachine) -> PyResult {
382-
Self::default()
383-
.into_ref_with_type(vm, cls)
384-
.map(Into::into)
382+
Self::default().into_ref_with_type(vm, cls).map(Into::into)
385383
}
386384
}
387385

vm/src/builtins/set.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,7 @@ impl PySetInner {
221221
self.retry_op_with_frozenset(needle, vm, |needle, vm| self.content.contains(vm, needle))
222222
}
223223

224-
fn compare(
225-
&self,
226-
other: &Self,
227-
op: PyComparisonOp,
228-
vm: &VirtualMachine,
229-
) -> PyResult<bool> {
224+
fn compare(&self, other: &Self, op: PyComparisonOp, vm: &VirtualMachine) -> PyResult<bool> {
230225
if op == PyComparisonOp::Ne {
231226
return self.compare(other, PyComparisonOp::Eq, vm).map(|eq| !eq);
232227
}
@@ -256,11 +251,7 @@ impl PySetInner {
256251
Ok(set)
257252
}
258253

259-
pub(super) fn intersection(
260-
&self,
261-
other: ArgIterable,
262-
vm: &VirtualMachine,
263-
) -> PyResult<Self> {
254+
pub(super) fn intersection(&self, other: ArgIterable, vm: &VirtualMachine) -> PyResult<Self> {
264255
let set = Self::default();
265256
for item in other.iter(vm)? {
266257
let obj = item?;
@@ -271,11 +262,7 @@ impl PySetInner {
271262
Ok(set)
272263
}
273264

274-
pub(super) fn difference(
275-
&self,
276-
other: ArgIterable,
277-
vm: &VirtualMachine,
278-
) -> PyResult<Self> {
265+
pub(super) fn difference(&self, other: ArgIterable, vm: &VirtualMachine) -> PyResult<Self> {
279266
let set = self.copy();
280267
for item in other.iter(vm)? {
281268
set.content.delete_if_exists(vm, &*item?)?;

vm/src/bytes_inner.rs

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,7 @@ impl PyBytesInner {
342342
self.elements.py_add(other)
343343
}
344344

345-
pub fn contains(
346-
&self,
347-
needle: Either<Self, PyIntRef>,
348-
vm: &VirtualMachine,
349-
) -> PyResult<bool> {
345+
pub fn contains(&self, needle: Either<Self, PyIntRef>, vm: &VirtualMachine) -> PyResult<bool> {
350346
Ok(match needle {
351347
Either::A(byte) => self.elements.contains_str(byte.elements.as_slice()),
352348
Either::B(int) => self.elements.contains(&int.as_bigint().byte_or(vm)?),
@@ -552,11 +548,7 @@ impl PyBytesInner {
552548
.py_count(needle.as_slice(), range, |h, n| h.find_iter(n).count()))
553549
}
554550

555-
pub fn join(
556-
&self,
557-
iterable: ArgIterable<Self>,
558-
vm: &VirtualMachine,
559-
) -> PyResult<Vec<u8>> {
551+
pub fn join(&self, iterable: ArgIterable<Self>, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
560552
let iter = iterable.iter(vm)?;
561553
self.elements.py_join(iter)
562554
}
@@ -575,11 +567,7 @@ impl PyBytesInner {
575567
Ok(self.elements.py_find(&needle, range, find))
576568
}
577569

578-
pub fn maketrans(
579-
from: Self,
580-
to: Self,
581-
vm: &VirtualMachine,
582-
) -> PyResult<Vec<u8>> {
570+
pub fn maketrans(from: Self, to: Self, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
583571
if from.len() != to.len() {
584572
return Err(vm.new_value_error("the two maketrans arguments must have equal length"));
585573
}
@@ -703,11 +691,7 @@ impl PyBytesInner {
703691
Ok(elements)
704692
}
705693

706-
pub fn partition(
707-
&self,
708-
sub: &Self,
709-
vm: &VirtualMachine,
710-
) -> PyResult<(Vec<u8>, bool, Vec<u8>)> {
694+
pub fn partition(&self, sub: &Self, vm: &VirtualMachine) -> PyResult<(Vec<u8>, bool, Vec<u8>)> {
711695
self.elements.py_partition(
712696
&sub.elements,
713697
|| self.elements.splitn_str(2, &sub.elements),
@@ -815,12 +799,7 @@ impl PyBytesInner {
815799
result
816800
}
817801

818-
pub fn replace_in_place(
819-
&self,
820-
from: Self,
821-
to: Self,
822-
max_count: Option<usize>,
823-
) -> Vec<u8> {
802+
pub fn replace_in_place(&self, from: Self, to: Self, max_count: Option<usize>) -> Vec<u8> {
824803
let len = from.len();
825804
let mut iter = self.elements.find_iter(&from.elements);
826805

vm/src/convert/try_from.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ impl<'a, T: PyPayload> TryFromBorrowedObject<'a> for &'a Py<T> {
123123

124124
impl TryFromObject for std::time::Duration {
125125
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self> {
126-
127126
if let Some(float) = obj.payload::<PyFloat>() {
128127
Ok(Self::from_secs_f64(float.to_f64()))
129128
} else if let Some(int) = obj.try_index_opt(vm) {

vm/src/format.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ impl IntoPyException for FormatSpecError {
1616
vm.new_value_error("Too many decimal digits in format string")
1717
}
1818
Self::PrecisionTooBig => vm.new_value_error("Precision too big"),
19-
Self::InvalidFormatSpecifier => {
20-
vm.new_value_error("Invalid format specifier")
21-
}
19+
Self::InvalidFormatSpecifier => vm.new_value_error("Invalid format specifier"),
2220
Self::UnspecifiedFormat(c1, c2) => {
2321
let msg = format!("Cannot specify '{c1}' with '{c2}'.");
2422
vm.new_value_error(msg)
@@ -34,12 +32,8 @@ impl IntoPyException for FormatSpecError {
3432
let msg = format!("{s} not allowed with integer format specifier 'c'");
3533
vm.new_value_error(msg)
3634
}
37-
Self::UnableToConvert => {
38-
vm.new_value_error("Unable to convert int to float")
39-
}
40-
Self::CodeNotInRange => {
41-
vm.new_overflow_error("%c arg not in range(0x110000)")
42-
}
35+
Self::UnableToConvert => vm.new_value_error("Unable to convert int to float"),
36+
Self::CodeNotInRange => vm.new_overflow_error("%c arg not in range(0x110000)"),
4337
Self::NotImplemented(c, s) => {
4438
let msg = format!("Format code '{c}' for object of type '{s}' not implemented yet");
4539
vm.new_value_error(msg)
@@ -51,9 +45,7 @@ impl IntoPyException for FormatSpecError {
5145
impl ToPyException for FormatParseError {
5246
fn to_pyexception(&self, vm: &VirtualMachine) -> PyBaseExceptionRef {
5347
match self {
54-
Self::UnmatchedBracket => {
55-
vm.new_value_error("expected '}' before end of string")
56-
}
48+
Self::UnmatchedBracket => vm.new_value_error("expected '}' before end of string"),
5749
_ => vm.new_value_error("Unexpected error parsing format string"),
5850
}
5951
}

vm/src/stdlib/ast/exception.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ impl Node for ruff::ExceptHandler {
1515
let _cls = _object.class();
1616
Ok(
1717
if _cls.is(pyast::NodeExceptHandlerExceptHandler::static_type()) {
18-
Self::ExceptHandler(
19-
ruff::ExceptHandlerExceptHandler::ast_from_object(_vm, source_code, _object)?,
20-
)
18+
Self::ExceptHandler(ruff::ExceptHandlerExceptHandler::ast_from_object(
19+
_vm,
20+
source_code,
21+
_object,
22+
)?)
2123
} else {
2224
return Err(_vm.new_type_error(format!(
2325
"expected some sort of excepthandler, but got {}",

vm/src/stdlib/io.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,9 +1967,7 @@ mod _io {
19671967
fn find_newline(&self, s: &Wtf8) -> Result<usize, usize> {
19681968
let len = s.len();
19691969
match self {
1970-
Self::Universal | Self::Lf => {
1971-
s.find("\n".as_ref()).map(|p| p + 1).ok_or(len)
1972-
}
1970+
Self::Universal | Self::Lf => s.find("\n".as_ref()).map(|p| p + 1).ok_or(len),
19731971
Self::Passthrough => {
19741972
let bytes = s.as_bytes();
19751973
memchr::memchr2(b'\n', b'\r', bytes)

0 commit comments

Comments
 (0)