Fix clippy::wrong_self_convention in polars plugin (#12737)

Expected `into_` for `fn(self) -> T`
This commit is contained in:
Stefan Holderbach 2024-05-02 19:31:51 +02:00 committed by GitHub
parent b88d8726d0
commit be6137d136
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 34 additions and 34 deletions

View File

@ -104,7 +104,7 @@ impl PluginCommand for CastDF {
PolarsPluginObject::NuExpression(expr) => { PolarsPluginObject::NuExpression(expr) => {
let dtype: String = call.req(0)?; let dtype: String = call.req(0)?;
let dtype = str_to_dtype(&dtype, call.head)?; 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) expr.to_pipeline_data(plugin, engine, call.head)
} }
_ => Err(cant_convert_err( _ => Err(cant_convert_err(

View File

@ -103,7 +103,7 @@ impl PluginCommand for FirstDF {
command(plugin, engine, call, df).map_err(|e| e.into()) command(plugin, engine, call, df).map_err(|e| e.into())
} else { } else {
let expr = NuExpression::try_from_value(plugin, &value)?; 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) expr.to_pipeline_data(plugin, engine, call.head)
.map_err(LabeledError::from) .map_err(LabeledError::from)

View File

@ -78,7 +78,7 @@ impl PluginCommand for LastDF {
command(plugin, engine, call, df).map_err(|e| e.into()) command(plugin, engine, call, df).map_err(|e| e.into())
} else { } else {
let expr = NuExpression::try_from_value(plugin, &value)?; 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) expr.to_pipeline_data(plugin, engine, call.head)
.map_err(LabeledError::from) .map_err(LabeledError::from)

View File

@ -67,7 +67,7 @@ impl PluginCommand for ExprAlias {
let alias: String = call.req(0)?; let alias: String = call.req(0)?;
let expr = NuExpression::try_from_pipeline(plugin, input, call.head)?; 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) expr.to_pipeline_data(plugin, engine, call.head)
.map_err(LabeledError::from) .map_err(LabeledError::from)

View File

@ -62,7 +62,7 @@ impl PluginCommand for ExprArgWhere {
) -> Result<PipelineData, LabeledError> { ) -> Result<PipelineData, LabeledError> {
let value: Value = call.req(0)?; let value: Value = call.req(0)?;
let expr = NuExpression::try_from_value(plugin, &value)?; 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) expr.to_pipeline_data(plugin, engine, call.head)
.map_err(LabeledError::from) .map_err(LabeledError::from)
} }

View File

@ -127,7 +127,7 @@ impl PluginCommand for ExprDatePart {
let part: Spanned<String> = call.req(0)?; let part: Spanned<String> = call.req(0)?;
let expr = NuExpression::try_from_pipeline(plugin, input, call.head)?; 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() { let expr: NuExpression = match part.item.as_str() {
"year" => expr_dt.year(), "year" => expr_dt.year(),
"quarter" => expr_dt.quarter(), "quarter" => expr_dt.quarter(),

View File

@ -50,7 +50,7 @@ macro_rules! expr_command {
) -> Result<PipelineData, LabeledError> { ) -> Result<PipelineData, LabeledError> {
let expr = NuExpression::try_from_pipeline(plugin, input, call.head) let expr = NuExpression::try_from_pipeline(plugin, input, call.head)
.map_err(LabeledError::from)?; .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) expr.to_pipeline_data(plugin, engine, call.head)
.map_err(LabeledError::from) .map_err(LabeledError::from)
} }
@ -181,7 +181,7 @@ macro_rules! lazy_expr_command {
} else { } else {
let expr = let expr =
NuExpression::try_from_value(plugin, &value).map_err(LabeledError::from)?; 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) expr.to_pipeline_data(plugin, engine, call.head)
.map_err(LabeledError::from) .map_err(LabeledError::from)
} }
@ -261,7 +261,7 @@ macro_rules! lazy_expr_command {
.map_err(LabeledError::from) .map_err(LabeledError::from)
} else { } else {
let expr = NuExpression::try_from_value(plugin, &value)?; 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) expr.to_pipeline_data(plugin, engine, call.head)
.map_err(LabeledError::from) .map_err(LabeledError::from)
} }

View File

@ -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) expr.to_pipeline_data(plugin, engine, call.head)
} }

View File

@ -101,9 +101,9 @@ impl PluginCommand for ExprOtherwise {
let value = input.into_value(call.head); let value = input.into_value(call.head);
let complete: NuExpression = match NuWhen::try_from_value(plugin, &value)?.when_type { 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 NuWhenType::ChainedThen(chained_when) => chained_when
.otherwise(otherwise_predicate.to_polars()) .otherwise(otherwise_predicate.into_polars())
.into(), .into(),
}; };
complete complete

View File

@ -113,17 +113,17 @@ impl PluginCommand for ExprWhen {
let value = input.into_value(call.head); let value = input.into_value(call.head);
let when_then: NuWhen = match value { let when_then: NuWhen = match value {
Value::Nothing { .. } => when(when_predicate.to_polars()) Value::Nothing { .. } => when(when_predicate.into_polars())
.then(then_predicate.to_polars()) .then(then_predicate.into_polars())
.into(), .into(),
v => match NuWhen::try_from_value(plugin, &v)?.when_type { v => match NuWhen::try_from_value(plugin, &v)?.when_type {
NuWhenType::Then(when_then) => when_then NuWhenType::Then(when_then) => when_then
.when(when_predicate.to_polars()) .when(when_predicate.into_polars())
.then(then_predicate.to_polars()) .then(then_predicate.into_polars())
.into(), .into(),
NuWhenType::ChainedThen(when_then_then) => when_then_then NuWhenType::ChainedThen(when_then_then) => when_then_then
.when(when_predicate.to_polars()) .when(when_predicate.into_polars())
.then(then_predicate.to_polars()) .then(then_predicate.into_polars())
.into(), .into(),
}, },
}; };

View File

@ -160,7 +160,7 @@ pub(crate) fn explode_expr(
call: &EvaluatedCall, call: &EvaluatedCall,
expr: NuExpression, expr: NuExpression,
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
let expr: NuExpression = expr.to_polars().explode().into(); let expr: NuExpression = expr.into_polars().explode().into();
expr.to_pipeline_data(plugin, engine, call.head) expr.to_pipeline_data(plugin, engine, call.head)
} }

View File

@ -168,8 +168,8 @@ fn cmd_expr(
expr: NuExpression, expr: NuExpression,
fill: Value, fill: Value,
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
let fill = NuExpression::try_from_value(plugin, &fill)?.to_polars(); let fill = NuExpression::try_from_value(plugin, &fill)?.into_polars();
let expr: NuExpression = expr.to_polars().fill_nan(fill).into(); let expr: NuExpression = expr.into_polars().fill_nan(fill).into();
expr.to_pipeline_data(plugin, engine, call.head) expr.to_pipeline_data(plugin, engine, call.head)
} }

View File

@ -95,7 +95,7 @@ fn cmd_lazy(
lazy: NuLazyFrame, lazy: NuLazyFrame,
fill: Value, fill: Value,
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
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)); let lazy = NuLazyFrame::new(lazy.from_eager, lazy.to_polars().fill_null(expr));
lazy.to_pipeline_data(plugin, engine, call.head) lazy.to_pipeline_data(plugin, engine, call.head)
} }
@ -107,8 +107,8 @@ fn cmd_expr(
expr: NuExpression, expr: NuExpression,
fill: Value, fill: Value,
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
let fill = NuExpression::try_from_value(plugin, &fill)?.to_polars(); let fill = NuExpression::try_from_value(plugin, &fill)?.into_polars();
let expr: NuExpression = expr.to_polars().fill_null(fill).into(); let expr: NuExpression = expr.into_polars().fill_null(fill).into();
expr.to_pipeline_data(plugin, engine, call.head) expr.to_pipeline_data(plugin, engine, call.head)
} }

View File

@ -87,7 +87,7 @@ fn command(
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
let lazy = NuLazyFrame::new( let lazy = NuLazyFrame::new(
lazy.from_eager, 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) lazy.to_pipeline_data(plugin, engine, call.head)
} }

View File

@ -94,7 +94,7 @@ impl PluginCommand for LazyMedian {
PolarsPluginObject::NuDataFrame(df) => command(plugin, engine, call, df.lazy()), PolarsPluginObject::NuDataFrame(df) => command(plugin, engine, call, df.lazy()),
PolarsPluginObject::NuLazyFrame(lazy) => command(plugin, engine, call, lazy), PolarsPluginObject::NuLazyFrame(lazy) => command(plugin, engine, call, lazy),
PolarsPluginObject::NuExpression(expr) => { 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) expr.to_pipeline_data(plugin, engine, call.head)
} }
_ => Err(cant_convert_err( _ => Err(cant_convert_err(

View File

@ -106,7 +106,7 @@ impl PluginCommand for LazyQuantile {
PolarsPluginObject::NuLazyFrame(lazy) => command(plugin, engine, call, lazy, quantile), PolarsPluginObject::NuLazyFrame(lazy) => command(plugin, engine, call, lazy, quantile),
PolarsPluginObject::NuExpression(expr) => { PolarsPluginObject::NuExpression(expr) => {
let expr: NuExpression = expr let expr: NuExpression = expr
.to_polars() .into_polars()
.quantile(lit(quantile), QuantileInterpolOptions::default()) .quantile(lit(quantile), QuantileInterpolOptions::default())
.into(); .into();
expr.to_pipeline_data(plugin, engine, call.head) expr.to_pipeline_data(plugin, engine, call.head)

View File

@ -86,7 +86,7 @@ impl PluginCommand for IsNotNull {
command(plugin, engine, call, lazy.collect(call.head)?) command(plugin, engine, call, lazy.collect(call.head)?)
} }
PolarsPluginObject::NuExpression(expr) => { 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) expr.to_pipeline_data(plugin, engine, call.head)
} }
_ => Err(cant_convert_err( _ => Err(cant_convert_err(

View File

@ -88,7 +88,7 @@ impl PluginCommand for IsNull {
command(plugin, engine, call, lazy.collect(call.head)?) command(plugin, engine, call, lazy.collect(call.head)?)
} }
PolarsPluginObject::NuExpression(expr) => { 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) expr.to_pipeline_data(plugin, engine, call.head)
} }
_ => Err(cant_convert_err( _ => Err(cant_convert_err(

View File

@ -78,7 +78,7 @@ impl PluginCommand for NUnique {
command(plugin, engine, call, lazy.collect(call.head)?) command(plugin, engine, call, lazy.collect(call.head)?)
} }
PolarsPluginObject::NuExpression(expr) => { 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) expr.to_pipeline_data(plugin, engine, call.head)
} }
_ => Err(cant_convert_err( _ => Err(cant_convert_err(

View File

@ -112,7 +112,7 @@ fn command_lazy(
let lazy: NuLazyFrame = match fill { let lazy: NuLazyFrame = match fill {
Some(ref 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() lazy.shift_and_fill(lit(shift), expr).into()
} }
None => lazy.shift(shift).into(), None => lazy.shift(shift).into(),

View File

@ -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") self.expr.expect("Expression cannot be none to convert")
} }
@ -121,7 +121,7 @@ impl ExtractedExpr {
match value { match value {
Value::String { val, .. } => Ok(ExtractedExpr::Single(col(val.as_str()))), Value::String { val, .. } => Ok(ExtractedExpr::Single(col(val.as_str()))),
Value::Custom { .. } => NuExpression::try_from_value(plugin, &value) Value::Custom { .. } => NuExpression::try_from_value(plugin, &value)
.map(NuExpression::to_polars) .map(NuExpression::into_polars)
.map(ExtractedExpr::Single), .map(ExtractedExpr::Single),
Value::List { vals, .. } => vals Value::List { vals, .. } => vals
.into_iter() .into_iter()

View File

@ -72,7 +72,7 @@ impl NuLazyFrame {
F: Fn(LazyFrame, Expr) -> LazyFrame, F: Fn(LazyFrame, Expr) -> LazyFrame,
{ {
let df = self.to_polars(); let df = self.to_polars();
let expr = expr.to_polars(); let expr = expr.into_polars();
let new_frame = f(df, expr); let new_frame = f(df, expr);
Self::new(self.from_eager, new_frame) Self::new(self.from_eager, new_frame)
} }