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) => {
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(

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -62,7 +62,7 @@ impl PluginCommand for ExprArgWhere {
) -> Result<PipelineData, LabeledError> {
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)
}

View file

@ -127,7 +127,7 @@ impl PluginCommand for ExprDatePart {
let part: Spanned<String> = 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(),

View file

@ -50,7 +50,7 @@ macro_rules! expr_command {
) -> Result<PipelineData, LabeledError> {
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)
}

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)
}

View file

@ -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

View file

@ -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(),
},
};

View file

@ -160,7 +160,7 @@ pub(crate) fn explode_expr(
call: &EvaluatedCall,
expr: NuExpression,
) -> 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)
}

View file

@ -168,8 +168,8 @@ fn cmd_expr(
expr: NuExpression,
fill: Value,
) -> Result<PipelineData, ShellError> {
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)
}

View file

@ -95,7 +95,7 @@ fn cmd_lazy(
lazy: NuLazyFrame,
fill: Value,
) -> 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));
lazy.to_pipeline_data(plugin, engine, call.head)
}
@ -107,8 +107,8 @@ fn cmd_expr(
expr: NuExpression,
fill: Value,
) -> Result<PipelineData, ShellError> {
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)
}

View file

@ -87,7 +87,7 @@ fn command(
) -> Result<PipelineData, ShellError> {
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)
}

View file

@ -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(

View file

@ -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)

View file

@ -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(

View file

@ -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(

View file

@ -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(

View file

@ -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(),

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")
}
@ -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()

View file

@ -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)
}