From be6137d13652506476f663b69e58d6c135268470 Mon Sep 17 00:00:00 2001 From: Stefan Holderbach Date: Thu, 2 May 2024 19:31:51 +0200 Subject: [PATCH] Fix clippy::wrong_self_convention in polars plugin (#12737) Expected `into_` for `fn(self) -> T` --- crates/nu_plugin_polars/src/dataframe/eager/cast.rs | 2 +- crates/nu_plugin_polars/src/dataframe/eager/first.rs | 2 +- crates/nu_plugin_polars/src/dataframe/eager/last.rs | 2 +- .../src/dataframe/expressions/alias.rs | 2 +- .../src/dataframe/expressions/arg_where.rs | 2 +- .../src/dataframe/expressions/datepart.rs | 2 +- .../src/dataframe/expressions/expressions_macro.rs | 6 +++--- .../src/dataframe/expressions/is_in.rs | 2 +- .../src/dataframe/expressions/otherwise.rs | 4 ++-- .../src/dataframe/expressions/when.rs | 12 ++++++------ .../nu_plugin_polars/src/dataframe/lazy/explode.rs | 2 +- .../nu_plugin_polars/src/dataframe/lazy/fill_nan.rs | 4 ++-- .../nu_plugin_polars/src/dataframe/lazy/fill_null.rs | 6 +++--- crates/nu_plugin_polars/src/dataframe/lazy/filter.rs | 2 +- crates/nu_plugin_polars/src/dataframe/lazy/median.rs | 2 +- .../nu_plugin_polars/src/dataframe/lazy/quantile.rs | 2 +- .../src/dataframe/series/masks/is_not_null.rs | 2 +- .../src/dataframe/series/masks/is_null.rs | 2 +- .../src/dataframe/series/n_unique.rs | 2 +- .../nu_plugin_polars/src/dataframe/series/shift.rs | 2 +- .../src/dataframe/values/nu_expression/mod.rs | 4 ++-- .../src/dataframe/values/nu_lazyframe/mod.rs | 2 +- 22 files changed, 34 insertions(+), 34 deletions(-) diff --git a/crates/nu_plugin_polars/src/dataframe/eager/cast.rs b/crates/nu_plugin_polars/src/dataframe/eager/cast.rs index 23cbb0bc7c..074e162201 100644 --- a/crates/nu_plugin_polars/src/dataframe/eager/cast.rs +++ b/crates/nu_plugin_polars/src/dataframe/eager/cast.rs @@ -104,7 +104,7 @@ impl PluginCommand for CastDF { PolarsPluginObject::NuExpression(expr) => { let dtype: String = call.req(0)?; let dtype = str_to_dtype(&dtype, call.head)?; - let expr: NuExpression = expr.to_polars().cast(dtype).into(); + let expr: NuExpression = expr.into_polars().cast(dtype).into(); expr.to_pipeline_data(plugin, engine, call.head) } _ => Err(cant_convert_err( diff --git a/crates/nu_plugin_polars/src/dataframe/eager/first.rs b/crates/nu_plugin_polars/src/dataframe/eager/first.rs index 6bbdc66f75..69f80e42c0 100644 --- a/crates/nu_plugin_polars/src/dataframe/eager/first.rs +++ b/crates/nu_plugin_polars/src/dataframe/eager/first.rs @@ -103,7 +103,7 @@ impl PluginCommand for FirstDF { command(plugin, engine, call, df).map_err(|e| e.into()) } else { let expr = NuExpression::try_from_value(plugin, &value)?; - let expr: NuExpression = expr.to_polars().first().into(); + let expr: NuExpression = expr.into_polars().first().into(); expr.to_pipeline_data(plugin, engine, call.head) .map_err(LabeledError::from) diff --git a/crates/nu_plugin_polars/src/dataframe/eager/last.rs b/crates/nu_plugin_polars/src/dataframe/eager/last.rs index 840fe063e9..0da0832d9b 100644 --- a/crates/nu_plugin_polars/src/dataframe/eager/last.rs +++ b/crates/nu_plugin_polars/src/dataframe/eager/last.rs @@ -78,7 +78,7 @@ impl PluginCommand for LastDF { command(plugin, engine, call, df).map_err(|e| e.into()) } else { let expr = NuExpression::try_from_value(plugin, &value)?; - let expr: NuExpression = expr.to_polars().last().into(); + let expr: NuExpression = expr.into_polars().last().into(); expr.to_pipeline_data(plugin, engine, call.head) .map_err(LabeledError::from) diff --git a/crates/nu_plugin_polars/src/dataframe/expressions/alias.rs b/crates/nu_plugin_polars/src/dataframe/expressions/alias.rs index 93ed234443..c780f13d9f 100644 --- a/crates/nu_plugin_polars/src/dataframe/expressions/alias.rs +++ b/crates/nu_plugin_polars/src/dataframe/expressions/alias.rs @@ -67,7 +67,7 @@ impl PluginCommand for ExprAlias { let alias: String = call.req(0)?; let expr = NuExpression::try_from_pipeline(plugin, input, call.head)?; - let expr: NuExpression = expr.to_polars().alias(alias.as_str()).into(); + let expr: NuExpression = expr.into_polars().alias(alias.as_str()).into(); expr.to_pipeline_data(plugin, engine, call.head) .map_err(LabeledError::from) diff --git a/crates/nu_plugin_polars/src/dataframe/expressions/arg_where.rs b/crates/nu_plugin_polars/src/dataframe/expressions/arg_where.rs index 07ae483fc5..a9d29c3b14 100644 --- a/crates/nu_plugin_polars/src/dataframe/expressions/arg_where.rs +++ b/crates/nu_plugin_polars/src/dataframe/expressions/arg_where.rs @@ -62,7 +62,7 @@ impl PluginCommand for ExprArgWhere { ) -> Result { let value: Value = call.req(0)?; let expr = NuExpression::try_from_value(plugin, &value)?; - let expr: NuExpression = arg_where(expr.to_polars()).into(); + let expr: NuExpression = arg_where(expr.into_polars()).into(); expr.to_pipeline_data(plugin, engine, call.head) .map_err(LabeledError::from) } diff --git a/crates/nu_plugin_polars/src/dataframe/expressions/datepart.rs b/crates/nu_plugin_polars/src/dataframe/expressions/datepart.rs index 02fbb1bf34..1cbb5fa532 100644 --- a/crates/nu_plugin_polars/src/dataframe/expressions/datepart.rs +++ b/crates/nu_plugin_polars/src/dataframe/expressions/datepart.rs @@ -127,7 +127,7 @@ impl PluginCommand for ExprDatePart { let part: Spanned = call.req(0)?; let expr = NuExpression::try_from_pipeline(plugin, input, call.head)?; - let expr_dt = expr.to_polars().dt(); + let expr_dt = expr.into_polars().dt(); let expr: NuExpression = match part.item.as_str() { "year" => expr_dt.year(), "quarter" => expr_dt.quarter(), diff --git a/crates/nu_plugin_polars/src/dataframe/expressions/expressions_macro.rs b/crates/nu_plugin_polars/src/dataframe/expressions/expressions_macro.rs index fe79b9e28e..1a566f6989 100644 --- a/crates/nu_plugin_polars/src/dataframe/expressions/expressions_macro.rs +++ b/crates/nu_plugin_polars/src/dataframe/expressions/expressions_macro.rs @@ -50,7 +50,7 @@ macro_rules! expr_command { ) -> Result { let expr = NuExpression::try_from_pipeline(plugin, input, call.head) .map_err(LabeledError::from)?; - let expr: NuExpression = expr.to_polars().$func().into(); + let expr: NuExpression = expr.into_polars().$func().into(); expr.to_pipeline_data(plugin, engine, call.head) .map_err(LabeledError::from) } @@ -181,7 +181,7 @@ macro_rules! lazy_expr_command { } else { let expr = NuExpression::try_from_value(plugin, &value).map_err(LabeledError::from)?; - let expr: NuExpression = expr.to_polars().$func().into(); + let expr: NuExpression = expr.into_polars().$func().into(); expr.to_pipeline_data(plugin, engine, call.head) .map_err(LabeledError::from) } @@ -261,7 +261,7 @@ macro_rules! lazy_expr_command { .map_err(LabeledError::from) } else { let expr = NuExpression::try_from_value(plugin, &value)?; - let expr: NuExpression = expr.to_polars().$func($ddof).into(); + let expr: NuExpression = expr.into_polars().$func($ddof).into(); expr.to_pipeline_data(plugin, engine, call.head) .map_err(LabeledError::from) } diff --git a/crates/nu_plugin_polars/src/dataframe/expressions/is_in.rs b/crates/nu_plugin_polars/src/dataframe/expressions/is_in.rs index b931a17764..1f270837bb 100644 --- a/crates/nu_plugin_polars/src/dataframe/expressions/is_in.rs +++ b/crates/nu_plugin_polars/src/dataframe/expressions/is_in.rs @@ -153,7 +153,7 @@ fn command_expr( }); } - let expr: NuExpression = expr.to_polars().is_in(lit(list)).into(); + let expr: NuExpression = expr.into_polars().is_in(lit(list)).into(); expr.to_pipeline_data(plugin, engine, call.head) } diff --git a/crates/nu_plugin_polars/src/dataframe/expressions/otherwise.rs b/crates/nu_plugin_polars/src/dataframe/expressions/otherwise.rs index e2697f7167..c887789268 100644 --- a/crates/nu_plugin_polars/src/dataframe/expressions/otherwise.rs +++ b/crates/nu_plugin_polars/src/dataframe/expressions/otherwise.rs @@ -101,9 +101,9 @@ impl PluginCommand for ExprOtherwise { let value = input.into_value(call.head); let complete: NuExpression = match NuWhen::try_from_value(plugin, &value)?.when_type { - NuWhenType::Then(then) => then.otherwise(otherwise_predicate.to_polars()).into(), + NuWhenType::Then(then) => then.otherwise(otherwise_predicate.into_polars()).into(), NuWhenType::ChainedThen(chained_when) => chained_when - .otherwise(otherwise_predicate.to_polars()) + .otherwise(otherwise_predicate.into_polars()) .into(), }; complete diff --git a/crates/nu_plugin_polars/src/dataframe/expressions/when.rs b/crates/nu_plugin_polars/src/dataframe/expressions/when.rs index 5ea542619a..1639ed44be 100644 --- a/crates/nu_plugin_polars/src/dataframe/expressions/when.rs +++ b/crates/nu_plugin_polars/src/dataframe/expressions/when.rs @@ -113,17 +113,17 @@ impl PluginCommand for ExprWhen { let value = input.into_value(call.head); let when_then: NuWhen = match value { - Value::Nothing { .. } => when(when_predicate.to_polars()) - .then(then_predicate.to_polars()) + Value::Nothing { .. } => when(when_predicate.into_polars()) + .then(then_predicate.into_polars()) .into(), v => match NuWhen::try_from_value(plugin, &v)?.when_type { NuWhenType::Then(when_then) => when_then - .when(when_predicate.to_polars()) - .then(then_predicate.to_polars()) + .when(when_predicate.into_polars()) + .then(then_predicate.into_polars()) .into(), NuWhenType::ChainedThen(when_then_then) => when_then_then - .when(when_predicate.to_polars()) - .then(then_predicate.to_polars()) + .when(when_predicate.into_polars()) + .then(then_predicate.into_polars()) .into(), }, }; diff --git a/crates/nu_plugin_polars/src/dataframe/lazy/explode.rs b/crates/nu_plugin_polars/src/dataframe/lazy/explode.rs index b1fb562eb8..b0609d7a3c 100644 --- a/crates/nu_plugin_polars/src/dataframe/lazy/explode.rs +++ b/crates/nu_plugin_polars/src/dataframe/lazy/explode.rs @@ -160,7 +160,7 @@ pub(crate) fn explode_expr( call: &EvaluatedCall, expr: NuExpression, ) -> Result { - let expr: NuExpression = expr.to_polars().explode().into(); + let expr: NuExpression = expr.into_polars().explode().into(); expr.to_pipeline_data(plugin, engine, call.head) } diff --git a/crates/nu_plugin_polars/src/dataframe/lazy/fill_nan.rs b/crates/nu_plugin_polars/src/dataframe/lazy/fill_nan.rs index 7c5cdfe574..851be588f9 100644 --- a/crates/nu_plugin_polars/src/dataframe/lazy/fill_nan.rs +++ b/crates/nu_plugin_polars/src/dataframe/lazy/fill_nan.rs @@ -168,8 +168,8 @@ fn cmd_expr( expr: NuExpression, fill: Value, ) -> Result { - let fill = NuExpression::try_from_value(plugin, &fill)?.to_polars(); - let expr: NuExpression = expr.to_polars().fill_nan(fill).into(); + let fill = NuExpression::try_from_value(plugin, &fill)?.into_polars(); + let expr: NuExpression = expr.into_polars().fill_nan(fill).into(); expr.to_pipeline_data(plugin, engine, call.head) } diff --git a/crates/nu_plugin_polars/src/dataframe/lazy/fill_null.rs b/crates/nu_plugin_polars/src/dataframe/lazy/fill_null.rs index a70e2b72ab..e68a6829f0 100644 --- a/crates/nu_plugin_polars/src/dataframe/lazy/fill_null.rs +++ b/crates/nu_plugin_polars/src/dataframe/lazy/fill_null.rs @@ -95,7 +95,7 @@ fn cmd_lazy( lazy: NuLazyFrame, fill: Value, ) -> Result { - let expr = NuExpression::try_from_value(plugin, &fill)?.to_polars(); + let expr = NuExpression::try_from_value(plugin, &fill)?.into_polars(); let lazy = NuLazyFrame::new(lazy.from_eager, lazy.to_polars().fill_null(expr)); lazy.to_pipeline_data(plugin, engine, call.head) } @@ -107,8 +107,8 @@ fn cmd_expr( expr: NuExpression, fill: Value, ) -> Result { - let fill = NuExpression::try_from_value(plugin, &fill)?.to_polars(); - let expr: NuExpression = expr.to_polars().fill_null(fill).into(); + let fill = NuExpression::try_from_value(plugin, &fill)?.into_polars(); + let expr: NuExpression = expr.into_polars().fill_null(fill).into(); expr.to_pipeline_data(plugin, engine, call.head) } diff --git a/crates/nu_plugin_polars/src/dataframe/lazy/filter.rs b/crates/nu_plugin_polars/src/dataframe/lazy/filter.rs index 9e8d0aea8a..246976c2ee 100644 --- a/crates/nu_plugin_polars/src/dataframe/lazy/filter.rs +++ b/crates/nu_plugin_polars/src/dataframe/lazy/filter.rs @@ -87,7 +87,7 @@ fn command( ) -> Result { let lazy = NuLazyFrame::new( lazy.from_eager, - lazy.to_polars().filter(filter_expr.to_polars()), + lazy.to_polars().filter(filter_expr.into_polars()), ); lazy.to_pipeline_data(plugin, engine, call.head) } diff --git a/crates/nu_plugin_polars/src/dataframe/lazy/median.rs b/crates/nu_plugin_polars/src/dataframe/lazy/median.rs index c31177a5a2..c3cfdba099 100644 --- a/crates/nu_plugin_polars/src/dataframe/lazy/median.rs +++ b/crates/nu_plugin_polars/src/dataframe/lazy/median.rs @@ -94,7 +94,7 @@ impl PluginCommand for LazyMedian { PolarsPluginObject::NuDataFrame(df) => command(plugin, engine, call, df.lazy()), PolarsPluginObject::NuLazyFrame(lazy) => command(plugin, engine, call, lazy), PolarsPluginObject::NuExpression(expr) => { - let expr: NuExpression = expr.to_polars().median().into(); + let expr: NuExpression = expr.into_polars().median().into(); expr.to_pipeline_data(plugin, engine, call.head) } _ => Err(cant_convert_err( diff --git a/crates/nu_plugin_polars/src/dataframe/lazy/quantile.rs b/crates/nu_plugin_polars/src/dataframe/lazy/quantile.rs index ede9c905ed..d8cb3e4cb6 100644 --- a/crates/nu_plugin_polars/src/dataframe/lazy/quantile.rs +++ b/crates/nu_plugin_polars/src/dataframe/lazy/quantile.rs @@ -106,7 +106,7 @@ impl PluginCommand for LazyQuantile { PolarsPluginObject::NuLazyFrame(lazy) => command(plugin, engine, call, lazy, quantile), PolarsPluginObject::NuExpression(expr) => { let expr: NuExpression = expr - .to_polars() + .into_polars() .quantile(lit(quantile), QuantileInterpolOptions::default()) .into(); expr.to_pipeline_data(plugin, engine, call.head) diff --git a/crates/nu_plugin_polars/src/dataframe/series/masks/is_not_null.rs b/crates/nu_plugin_polars/src/dataframe/series/masks/is_not_null.rs index 8ded0329d6..218cd116b4 100644 --- a/crates/nu_plugin_polars/src/dataframe/series/masks/is_not_null.rs +++ b/crates/nu_plugin_polars/src/dataframe/series/masks/is_not_null.rs @@ -86,7 +86,7 @@ impl PluginCommand for IsNotNull { command(plugin, engine, call, lazy.collect(call.head)?) } PolarsPluginObject::NuExpression(expr) => { - let expr: NuExpression = expr.to_polars().is_not_null().into(); + let expr: NuExpression = expr.into_polars().is_not_null().into(); expr.to_pipeline_data(plugin, engine, call.head) } _ => Err(cant_convert_err( diff --git a/crates/nu_plugin_polars/src/dataframe/series/masks/is_null.rs b/crates/nu_plugin_polars/src/dataframe/series/masks/is_null.rs index b67e4e7702..beb3793661 100644 --- a/crates/nu_plugin_polars/src/dataframe/series/masks/is_null.rs +++ b/crates/nu_plugin_polars/src/dataframe/series/masks/is_null.rs @@ -88,7 +88,7 @@ impl PluginCommand for IsNull { command(plugin, engine, call, lazy.collect(call.head)?) } PolarsPluginObject::NuExpression(expr) => { - let expr: NuExpression = expr.to_polars().is_null().into(); + let expr: NuExpression = expr.into_polars().is_null().into(); expr.to_pipeline_data(plugin, engine, call.head) } _ => Err(cant_convert_err( diff --git a/crates/nu_plugin_polars/src/dataframe/series/n_unique.rs b/crates/nu_plugin_polars/src/dataframe/series/n_unique.rs index be6320208d..5426ef6d1d 100644 --- a/crates/nu_plugin_polars/src/dataframe/series/n_unique.rs +++ b/crates/nu_plugin_polars/src/dataframe/series/n_unique.rs @@ -78,7 +78,7 @@ impl PluginCommand for NUnique { command(plugin, engine, call, lazy.collect(call.head)?) } PolarsPluginObject::NuExpression(expr) => { - let expr: NuExpression = expr.to_polars().n_unique().into(); + let expr: NuExpression = expr.into_polars().n_unique().into(); expr.to_pipeline_data(plugin, engine, call.head) } _ => Err(cant_convert_err( diff --git a/crates/nu_plugin_polars/src/dataframe/series/shift.rs b/crates/nu_plugin_polars/src/dataframe/series/shift.rs index 02e47b55c0..9b5f8b2f63 100644 --- a/crates/nu_plugin_polars/src/dataframe/series/shift.rs +++ b/crates/nu_plugin_polars/src/dataframe/series/shift.rs @@ -112,7 +112,7 @@ fn command_lazy( let lazy: NuLazyFrame = match fill { Some(ref fill) => { - let expr = NuExpression::try_from_value(plugin, fill)?.to_polars(); + let expr = NuExpression::try_from_value(plugin, fill)?.into_polars(); lazy.shift_and_fill(lit(shift), expr).into() } None => lazy.shift(shift).into(), diff --git a/crates/nu_plugin_polars/src/dataframe/values/nu_expression/mod.rs b/crates/nu_plugin_polars/src/dataframe/values/nu_expression/mod.rs index 34f655a608..96eab00d53 100644 --- a/crates/nu_plugin_polars/src/dataframe/values/nu_expression/mod.rs +++ b/crates/nu_plugin_polars/src/dataframe/values/nu_expression/mod.rs @@ -71,7 +71,7 @@ impl NuExpression { } } - pub fn to_polars(self) -> Expr { + pub fn into_polars(self) -> Expr { self.expr.expect("Expression cannot be none to convert") } @@ -121,7 +121,7 @@ impl ExtractedExpr { match value { Value::String { val, .. } => Ok(ExtractedExpr::Single(col(val.as_str()))), Value::Custom { .. } => NuExpression::try_from_value(plugin, &value) - .map(NuExpression::to_polars) + .map(NuExpression::into_polars) .map(ExtractedExpr::Single), Value::List { vals, .. } => vals .into_iter() diff --git a/crates/nu_plugin_polars/src/dataframe/values/nu_lazyframe/mod.rs b/crates/nu_plugin_polars/src/dataframe/values/nu_lazyframe/mod.rs index 86267dd51b..0f8d80c4b9 100644 --- a/crates/nu_plugin_polars/src/dataframe/values/nu_lazyframe/mod.rs +++ b/crates/nu_plugin_polars/src/dataframe/values/nu_lazyframe/mod.rs @@ -72,7 +72,7 @@ impl NuLazyFrame { F: Fn(LazyFrame, Expr) -> LazyFrame, { let df = self.to_polars(); - let expr = expr.to_polars(); + let expr = expr.into_polars(); let new_frame = f(df, expr); Self::new(self.from_eager, new_frame) }