mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Fix clippy lint and unblock a test case
This commit is contained in:
@@ -381,7 +381,6 @@ class LongTest(unittest.TestCase):
|
||||
self.assertRaises(ValueError, int, '-012395', 0)
|
||||
|
||||
|
||||
@unittest.expectedFailure # TODO: RUSTPYTHON
|
||||
def test_conversion(self):
|
||||
|
||||
class JustLong:
|
||||
|
||||
@@ -21,14 +21,6 @@ pub struct PyComplex {
|
||||
value: Complex64,
|
||||
}
|
||||
|
||||
impl<'a> BorrowValue<'a> for PyComplex {
|
||||
type Borrowed = &'a Complex64;
|
||||
|
||||
fn borrow_value(&'a self) -> Self::Borrowed {
|
||||
&self.value
|
||||
}
|
||||
}
|
||||
|
||||
impl PyValue for PyComplex {
|
||||
fn class(vm: &VirtualMachine) -> &PyTypeRef {
|
||||
&vm.ctx.types.complex_type
|
||||
@@ -53,13 +45,13 @@ pub fn init(context: &PyContext) {
|
||||
|
||||
fn try_complex(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult<Option<Complex64>> {
|
||||
if let Some(complex) = obj.payload_if_exact::<PyComplex>(vm) {
|
||||
return Ok(Some(complex.borrow_value().clone()));
|
||||
return Ok(Some(complex.value));
|
||||
}
|
||||
if let Some(method) = vm.get_method(obj.clone(), "__complex__") {
|
||||
let result = vm.invoke(&method?, ())?;
|
||||
// TODO: returning strict subclasses of complex in __complex__ is deprecated
|
||||
return match result.payload::<PyComplex>() {
|
||||
Some(complex_obj) => Ok(Some(complex_obj.borrow_value().clone())),
|
||||
Some(complex_obj) => Ok(Some(complex_obj.value)),
|
||||
None => Err(vm.new_type_error(format!(
|
||||
"__complex__ returned non-complex (type '{}')",
|
||||
result.class().name
|
||||
|
||||
@@ -26,14 +26,6 @@ pub struct PyFloat {
|
||||
value: f64,
|
||||
}
|
||||
|
||||
impl<'a> BorrowValue<'a> for PyFloat {
|
||||
type Borrowed = &'a f64;
|
||||
|
||||
fn borrow_value(&'a self) -> Self::Borrowed {
|
||||
&self.value
|
||||
}
|
||||
}
|
||||
|
||||
impl PyFloat {
|
||||
pub fn to_f64(self) -> f64 {
|
||||
self.value
|
||||
@@ -65,13 +57,13 @@ impl From<f64> for PyFloat {
|
||||
|
||||
pub(crate) fn try_float(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult<Option<f64>> {
|
||||
if let Some(float) = obj.payload_if_exact::<PyFloat>(vm) {
|
||||
return Ok(Some(float.borrow_value().clone()));
|
||||
return Ok(Some(float.value));
|
||||
}
|
||||
if let Some(method) = vm.get_method(obj.clone(), "__float__") {
|
||||
let result = vm.invoke(&method?, ())?;
|
||||
// TODO: returning strict subclasses of float in __float__ is deprecated
|
||||
return match result.payload::<PyFloat>() {
|
||||
Some(float_obj) => Ok(Some(float_obj.borrow_value().clone())),
|
||||
Some(float_obj) => Ok(Some(float_obj.value)),
|
||||
None => Err(vm.new_type_error(format!(
|
||||
"__float__ returned non-float (type '{}')",
|
||||
result.class().name
|
||||
|
||||
Reference in New Issue
Block a user