diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/append.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/append.rs index 3774751ffb..ac079d43a4 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/append.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/append.rs @@ -23,8 +23,10 @@ impl Command for AppendDF { Signature::build(self.name()) .required("other", SyntaxShape::Any, "dataframe to be appended") .switch("col", "appends in col orientation", Some('c')) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/columns.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/columns.rs index cdf97de7ef..0a7dccfb98 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/columns.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/columns.rs @@ -19,8 +19,7 @@ impl Command for ColumnsDF { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Any) + .input_output_type(Type::Custom("dataframe".into()), Type::Any) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/drop.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/drop.rs index 56bbc31925..dbf36d6fe2 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/drop.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/drop.rs @@ -23,8 +23,10 @@ impl Command for DropDF { fn signature(&self) -> Signature { Signature::build(self.name()) .rest("rest", SyntaxShape::Any, "column names to be dropped") - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/drop_duplicates.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/drop_duplicates.rs index ac8786049f..80b1ab61de 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/drop_duplicates.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/drop_duplicates.rs @@ -34,8 +34,10 @@ impl Command for DropDuplicates { "keeps last duplicate value (by default keeps first)", Some('l'), ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/drop_nulls.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/drop_nulls.rs index 0397e358d6..071db45ca9 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/drop_nulls.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/drop_nulls.rs @@ -27,8 +27,10 @@ impl Command for DropNulls { SyntaxShape::Table, "subset of columns to drop nulls", ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/dtypes.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/dtypes.rs index a38ba440cb..c7e2a8299c 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/dtypes.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/dtypes.rs @@ -19,8 +19,10 @@ impl Command for DataTypes { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/dummies.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/dummies.rs index a1c673a3cc..c0194ea305 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/dummies.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/dummies.rs @@ -20,8 +20,10 @@ impl Command for Dummies { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/filter_with.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/filter_with.rs index 733385ca52..88c40e336c 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/filter_with.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/filter_with.rs @@ -29,8 +29,10 @@ impl Command for FilterWith { SyntaxShape::Any, "boolean mask used to filter data", ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe or lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/first.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/first.rs index 458ecec525..839aaa7527 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/first.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/first.rs @@ -25,8 +25,10 @@ impl Command for FirstDF { SyntaxShape::Int, "starting from the front, the number of rows to return", ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/get.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/get.rs index 74174de789..e763974cb5 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/get.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/get.rs @@ -24,8 +24,10 @@ impl Command for GetDF { fn signature(&self) -> Signature { Signature::build(self.name()) .rest("rest", SyntaxShape::Any, "column names to sort dataframe") - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/last.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/last.rs index 0d7428a3c2..fe8a2b5e06 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/last.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/last.rs @@ -21,8 +21,10 @@ impl Command for LastDF { fn signature(&self) -> Signature { Signature::build(self.name()) .optional("rows", SyntaxShape::Int, "Number of rows for tail") - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/melt.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/melt.rs index 6ecff9120b..39a908fcfb 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/melt.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/melt.rs @@ -48,8 +48,10 @@ impl Command for MeltDF { "optional name for value column", Some('l'), ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/open.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/open.rs index e3aaffa375..45a906d656 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/open.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/open.rs @@ -68,8 +68,7 @@ impl Command for OpenDataFrame { "Columns to be selected from csv file. CSV and Parquet file", None, ) - .input_type(Type::Any) - .output_type(Type::Custom("dataframe".into())) + .input_output_type(Type::Any, Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/query_df.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/query_df.rs index 275f23da5e..1d76e0ae12 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/query_df.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/query_df.rs @@ -28,8 +28,10 @@ impl Command for QueryDf { fn signature(&self) -> Signature { Signature::build(self.name()) .required("sql", SyntaxShape::String, "sql query") - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/rename.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/rename.rs index ffe02d5c34..67cd8649f3 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/rename.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/rename.rs @@ -33,8 +33,10 @@ impl Command for RenameDF { SyntaxShape::Any, "New names for the selected column(s). A string or list of strings", ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe or lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/sample.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/sample.rs index 7bd8833bf1..4730ec09ec 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/sample.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/sample.rs @@ -41,8 +41,10 @@ impl Command for SampleDF { ) .switch("replace", "sample with replace", Some('e')) .switch("shuffle", "shuffle sample", Some('u')) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/shape.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/shape.rs index a121bf4b7a..71ca997767 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/shape.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/shape.rs @@ -22,8 +22,10 @@ impl Command for ShapeDF { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/slice.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/slice.rs index 67b3939bf9..21be93094b 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/slice.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/slice.rs @@ -25,8 +25,10 @@ impl Command for SliceDF { Signature::build(self.name()) .required("offset", SyntaxShape::Int, "start of slice") .required("size", SyntaxShape::Int, "size of slice") - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/summary.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/summary.rs index 29bb740e38..9d2e0197f9 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/summary.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/summary.rs @@ -29,8 +29,10 @@ impl Command for Summary { fn signature(&self) -> Signature { Signature::build(self.name()) .category(Category::Custom("dataframe".into())) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .named( "quantiles", SyntaxShape::Table, diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/take.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/take.rs index 114c77fe1a..4d2a4681fa 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/take.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/take.rs @@ -29,8 +29,10 @@ impl Command for TakeDF { SyntaxShape::Any, "list of indices used to take data", ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/to_arrow.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/to_arrow.rs index 7d0dc0960b..b4b4848042 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/to_arrow.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/to_arrow.rs @@ -25,8 +25,7 @@ impl Command for ToArrow { fn signature(&self) -> Signature { Signature::build(self.name()) .required("file", SyntaxShape::Filepath, "file path to save dataframe") - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Any) + .input_output_type(Type::Custom("dataframe".into()), Type::Any) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/to_csv.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/to_csv.rs index fc08520190..26d36f119e 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/to_csv.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/to_csv.rs @@ -32,8 +32,7 @@ impl Command for ToCSV { Some('d'), ) .switch("no-header", "Indicates if file doesn't have header", None) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Any) + .input_output_type(Type::Custom("dataframe".into()), Type::Any) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/to_df.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/to_df.rs index fb452968c7..45bf5ea42b 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/to_df.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/to_df.rs @@ -20,8 +20,7 @@ impl Command for ToDataFrame { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Any) - .output_type(Type::Custom("dataframe".into())) + .input_output_type(Type::Any, Type::Custom("dataframe".into())) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/to_json_lines.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/to_json_lines.rs index e255385102..976af7e585 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/to_json_lines.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/to_json_lines.rs @@ -25,8 +25,7 @@ impl Command for ToJsonLines { fn signature(&self) -> Signature { Signature::build(self.name()) .required("file", SyntaxShape::Filepath, "file path to save dataframe") - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Any) + .input_output_type(Type::Custom("dataframe".into()), Type::Any) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/to_nu.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/to_nu.rs index f0db9ef7f5..40c5f92a0d 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/to_nu.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/to_nu.rs @@ -28,8 +28,7 @@ impl Command for ToNu { Some('n'), ) .switch("tail", "shows tail rows", Some('t')) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Any) + .input_output_type(Type::Custom("dataframe".into()), Type::Any) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/to_parquet.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/to_parquet.rs index 2f9bcb2133..ab2421fbd0 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/to_parquet.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/to_parquet.rs @@ -25,8 +25,7 @@ impl Command for ToParquet { fn signature(&self) -> Signature { Signature::build(self.name()) .required("file", SyntaxShape::Filepath, "file path to save dataframe") - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Any) + .input_output_type(Type::Custom("dataframe".into()), Type::Any) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/eager/with_column.rs b/crates/nu-cmd-dataframe/src/dataframe/eager/with_column.rs index 09a7c977e0..17b195ec5f 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/eager/with_column.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/eager/with_column.rs @@ -27,8 +27,10 @@ impl Command for WithColumn { SyntaxShape::Any, "series to be added or expressions used to define the new columns", ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe or lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/alias.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/alias.rs index d03fc4f0eb..c672b18343 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/alias.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/alias.rs @@ -26,8 +26,10 @@ impl Command for ExprAlias { SyntaxShape::String, "Alias name for the expression", ) - .input_type(Type::Custom("expression".into())) - .output_type(Type::Custom("expression".into())) + .input_output_type( + Type::Custom("expression".into()), + Type::Custom("expression".into()), + ) .category(Category::Custom("expression".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/arg_where.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/arg_where.rs index aa8cb2dbe3..f04be2511e 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/arg_where.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/arg_where.rs @@ -22,8 +22,7 @@ impl Command for ExprArgWhere { fn signature(&self) -> Signature { Signature::build(self.name()) .required("column name", SyntaxShape::Any, "Expression to evaluate") - .input_type(Type::Any) - .output_type(Type::Custom("expression".into())) + .input_output_type(Type::Any, Type::Custom("expression".into())) .category(Category::Custom("expression".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/as_nu.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/as_nu.rs index 322e6958a0..8cd893ae45 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/as_nu.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/as_nu.rs @@ -20,8 +20,7 @@ impl Command for ExprAsNu { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("expression".into())) - .output_type(Type::Any) + .input_output_type(Type::Custom("expression".into()), Type::Any) .category(Category::Custom("expression".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/col.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/col.rs index 76f1c30a0f..8ff5ec5a74 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/col.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/col.rs @@ -26,8 +26,7 @@ impl Command for ExprCol { SyntaxShape::String, "Name of column to be used", ) - .input_type(Type::Any) - .output_type(Type::Custom("expression".into())) + .input_output_type(Type::Any, Type::Custom("expression".into())) .category(Category::Custom("expression".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/concat_str.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/concat_str.rs index 6a0f52c2de..789142c463 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/concat_str.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/concat_str.rs @@ -31,8 +31,7 @@ impl Command for ExprConcatStr { SyntaxShape::List(Box::new(SyntaxShape::Any)), "Expression(s) that define the string concatenation", ) - .input_type(Type::Any) - .output_type(Type::Custom("expression".into())) + .input_output_type(Type::Any, Type::Custom("expression".into())) .category(Category::Custom("expression".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/datepart.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/datepart.rs index bdecd50913..4cc157aaec 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/datepart.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/datepart.rs @@ -29,8 +29,10 @@ impl Command for ExprDatePart { SyntaxShape::String, "Part of the date to capture. Possible values are year, quarter, month, week, weekday, day, hour, minute, second, millisecond, microsecond, nanosecond", ) - .input_type(Type::Custom("expression".into())) - .output_type(Type::Custom("expression".into())) + .input_output_type( + Type::Custom("expression".into()), + Type::Custom("expression".into()), + ) .category(Category::Custom("expression".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/expressions_macro.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/expressions_macro.rs index fcb4695773..6ab69b27b3 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/expressions_macro.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/expressions_macro.rs @@ -26,8 +26,10 @@ macro_rules! expr_command { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("expression".into())) - .output_type(Type::Custom("expression".into())) + .input_output_type( + Type::Custom("expression".into()), + Type::Custom("expression".into()), + ) .category(Category::Custom("expression".into())) } @@ -85,8 +87,10 @@ macro_rules! expr_command { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("expression".into())) - .output_type(Type::Custom("expression".into())) + .input_output_type( + Type::Custom("expression".into()), + Type::Custom("expression".into()), + ) .category(Category::Custom("expression".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/is_in.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/is_in.rs index 42d77b50a5..587dd21bad 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/is_in.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/is_in.rs @@ -26,8 +26,10 @@ impl Command for ExprIsIn { SyntaxShape::List(Box::new(SyntaxShape::Any)), "List to check if values are in", ) - .input_type(Type::Custom("expression".into())) - .output_type(Type::Custom("expression".into())) + .input_output_type( + Type::Custom("expression".into()), + Type::Custom("expression".into()), + ) .category(Category::Custom("expression".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/lit.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/lit.rs index a69e18cc6c..2f964e72c3 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/lit.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/lit.rs @@ -25,8 +25,7 @@ impl Command for ExprLit { SyntaxShape::Any, "literal to construct the expression", ) - .input_type(Type::Any) - .output_type(Type::Custom("expression".into())) + .input_output_type(Type::Any, Type::Custom("expression".into())) .category(Category::Custom("expression".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/otherwise.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/otherwise.rs index 0cad793bf9..d1b4479af3 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/otherwise.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/otherwise.rs @@ -25,8 +25,7 @@ impl Command for ExprOtherwise { SyntaxShape::Any, "expression to apply when no when predicate matches", ) - .input_type(Type::Any) - .output_type(Type::Custom("expression".into())) + .input_output_type(Type::Any, Type::Custom("expression".into())) .category(Category::Custom("expression".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/quantile.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/quantile.rs index f88bc2340b..6952c27e68 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/quantile.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/quantile.rs @@ -26,8 +26,10 @@ impl Command for ExprQuantile { SyntaxShape::Number, "quantile value for quantile operation", ) - .input_type(Type::Custom("expression".into())) - .output_type(Type::Custom("expression".into())) + .input_output_type( + Type::Custom("expression".into()), + Type::Custom("expression".into()), + ) .category(Category::Custom("expression".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/expressions/when.rs b/crates/nu-cmd-dataframe/src/dataframe/expressions/when.rs index b90950cf02..26f358120f 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/expressions/when.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/expressions/when.rs @@ -31,8 +31,10 @@ impl Command for ExprWhen { SyntaxShape::Any, "expression that will be applied when predicate is true", ) - .input_type(Type::Custom("expression".into())) - .output_type(Type::Custom("expression".into())) + .input_output_type( + Type::Custom("expression".into()), + Type::Custom("expression".into()), + ) .category(Category::Custom("expression".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/aggregate.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/aggregate.rs index 44e005df8c..2e5e913ba9 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/aggregate.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/aggregate.rs @@ -27,8 +27,10 @@ impl Command for LazyAggregate { SyntaxShape::Any, "Expression(s) that define the aggregations to be applied", ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("lazyframe".into())) } @@ -121,7 +123,7 @@ impl Command for LazyAggregate { let group_by = NuLazyGroupBy::try_from_pipeline(input, call.head)?; if let Some(schema) = &group_by.schema { - for expr in &expressions { + for expr in expressions.iter() { if let Some(name) = get_col_name(expr) { let dtype = schema.get(name.as_str()); diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/collect.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/collect.rs index 208869f2cb..55b13f3047 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/collect.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/collect.rs @@ -21,8 +21,10 @@ impl Command for LazyCollect { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/fetch.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/fetch.rs index f1c7585470..2b9b417192 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/fetch.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/fetch.rs @@ -26,8 +26,10 @@ impl Command for LazyFetch { SyntaxShape::Int, "number of rows to be fetched from lazyframe", ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/fill_nan.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/fill_nan.rs index 82eb7dfbb4..9406fe3443 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/fill_nan.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/fill_nan.rs @@ -25,8 +25,10 @@ impl Command for LazyFillNA { SyntaxShape::Any, "Expression to use to fill the NAN values", ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/fill_null.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/fill_null.rs index 32fff5460d..445d5366e7 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/fill_null.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/fill_null.rs @@ -25,8 +25,10 @@ impl Command for LazyFillNull { SyntaxShape::Any, "Expression to use to fill the null values", ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/filter.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/filter.rs index b150b9d8a5..5250c8beed 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/filter.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/filter.rs @@ -26,8 +26,10 @@ impl Command for LazyFilter { SyntaxShape::Any, "Expression that define the column selection", ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/groupby.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/groupby.rs index 9a9337eb5c..99d4897819 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/groupby.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/groupby.rs @@ -26,8 +26,10 @@ impl Command for ToLazyGroupBy { SyntaxShape::Any, "Expression(s) that define the lazy group-by", ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/join.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/join.rs index 1689009982..58f4d6be86 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/join.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/join.rs @@ -38,8 +38,10 @@ impl Command for LazyJoin { "Suffix to use on columns with same name", Some('s'), ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/macro_commands.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/macro_commands.rs index 913fd87a2e..1765861c99 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/macro_commands.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/macro_commands.rs @@ -24,8 +24,10 @@ macro_rules! lazy_command { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("lazyframe".into())) } @@ -74,8 +76,10 @@ macro_rules! lazy_command { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/quantile.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/quantile.rs index 055f792f4c..8b42b3cec1 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/quantile.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/quantile.rs @@ -26,8 +26,10 @@ impl Command for LazyQuantile { SyntaxShape::Number, "quantile value for quantile operation", ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/select.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/select.rs index 2d67cfc2e7..18c9206e3f 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/select.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/select.rs @@ -25,8 +25,10 @@ impl Command for LazySelect { SyntaxShape::Any, "Expression(s) that define the column selection", ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/sort_by_expr.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/sort_by_expr.rs index 0ac9fc687b..5a3ca4e150 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/sort_by_expr.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/sort_by_expr.rs @@ -37,8 +37,10 @@ impl Command for LazySortBy { "nulls are shown last in the dataframe", Some('n'), ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/lazy/to_lazy.rs b/crates/nu-cmd-dataframe/src/dataframe/lazy/to_lazy.rs index 99aabc9f60..cfbcaf32b0 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/lazy/to_lazy.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/lazy/to_lazy.rs @@ -20,8 +20,7 @@ impl Command for ToLazyFrame { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Any) - .output_type(Type::Custom("dataframe".into())) + .input_output_type(Type::Any, Type::Custom("dataframe".into())) .category(Category::Custom("lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/all_false.rs b/crates/nu-cmd-dataframe/src/dataframe/series/all_false.rs index 391534245b..8f10398dc6 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/all_false.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/all_false.rs @@ -20,8 +20,10 @@ impl Command for AllFalse { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/all_true.rs b/crates/nu-cmd-dataframe/src/dataframe/series/all_true.rs index ac8dbf03aa..2f07567db1 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/all_true.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/all_true.rs @@ -20,8 +20,10 @@ impl Command for AllTrue { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/arg_max.rs b/crates/nu-cmd-dataframe/src/dataframe/series/arg_max.rs index aaec16f747..c517eb2acb 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/arg_max.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/arg_max.rs @@ -25,8 +25,10 @@ impl Command for ArgMax { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/arg_min.rs b/crates/nu-cmd-dataframe/src/dataframe/series/arg_min.rs index 953f7baf0e..fd7df8f5d2 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/arg_min.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/arg_min.rs @@ -25,8 +25,10 @@ impl Command for ArgMin { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/cumulative.rs b/crates/nu-cmd-dataframe/src/dataframe/series/cumulative.rs index 761da4eb7b..920ac8ef72 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/cumulative.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/cumulative.rs @@ -56,8 +56,10 @@ impl Command for Cumulative { Signature::build(self.name()) .required("type", SyntaxShape::String, "rolling operation") .switch("reverse", "Reverse cumulative calculation", Some('r')) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/as_date.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/as_date.rs index 83eeb5f2d9..2f24d4c4d7 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/as_date.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/as_date.rs @@ -31,9 +31,11 @@ impl Command for AsDate { Signature::build(self.name()) .required("format", SyntaxShape::String, "formatting date string") .switch("not-exact", "the format string may be contained in the date (e.g. foo-2021-01-01-bar could match 2021-01-01)", Some('n')) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) -.category(Category::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/as_datetime.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/as_datetime.rs index 49a1edd5ea..efa7df2d89 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/as_datetime.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/as_datetime.rs @@ -40,9 +40,11 @@ impl Command for AsDateTime { Signature::build(self.name()) .required("format", SyntaxShape::String, "formatting date time string") .switch("not-exact", "the format string may be contained in the date (e.g. foo-2021-01-01-bar could match 2021-01-01)", Some('n')) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) -.category(Category::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) + .category(Category::Custom("dataframe".into())) } fn examples(&self) -> Vec { diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_day.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_day.rs index f7af95ec77..51ded86e08 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_day.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_day.rs @@ -21,8 +21,10 @@ impl Command for GetDay { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_hour.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_hour.rs index 2731f582af..548edb4267 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_hour.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_hour.rs @@ -21,8 +21,10 @@ impl Command for GetHour { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_minute.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_minute.rs index 86d3867d51..de5dd9d5cf 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_minute.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_minute.rs @@ -21,8 +21,10 @@ impl Command for GetMinute { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_month.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_month.rs index d26afb2a40..58d0cba227 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_month.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_month.rs @@ -21,8 +21,10 @@ impl Command for GetMonth { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_nanosecond.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_nanosecond.rs index 8a3b074284..f36e4c7af4 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_nanosecond.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_nanosecond.rs @@ -21,8 +21,10 @@ impl Command for GetNanosecond { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_ordinal.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_ordinal.rs index 399685c1e9..40d245121e 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_ordinal.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_ordinal.rs @@ -21,8 +21,10 @@ impl Command for GetOrdinal { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_second.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_second.rs index 7a77ee4ae9..74b7fa8909 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_second.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_second.rs @@ -21,8 +21,10 @@ impl Command for GetSecond { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_week.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_week.rs index 115a027c26..ba39d18634 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_week.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_week.rs @@ -21,8 +21,10 @@ impl Command for GetWeek { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_weekday.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_weekday.rs index 906c812de0..668c32c640 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_weekday.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_weekday.rs @@ -21,8 +21,10 @@ impl Command for GetWeekDay { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_year.rs b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_year.rs index b31e949c09..991d347c71 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/date/get_year.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/date/get_year.rs @@ -21,8 +21,10 @@ impl Command for GetYear { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_sort.rs b/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_sort.rs index 38e01b46d3..9ac9314a25 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_sort.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_sort.rs @@ -27,8 +27,10 @@ impl Command for ArgSort { Signature::build(self.name()) .switch("reverse", "reverse order", Some('r')) .switch("nulls-last", "nulls ordered last", Some('n')) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_true.rs b/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_true.rs index 2a067c4297..63947b96f6 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_true.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_true.rs @@ -25,8 +25,10 @@ impl Command for ArgTrue { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_unique.rs b/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_unique.rs index 5824c59ecf..d8ca33c34f 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_unique.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/indexes/arg_unique.rs @@ -25,8 +25,10 @@ impl Command for ArgUnique { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/indexes/set_with_idx.rs b/crates/nu-cmd-dataframe/src/dataframe/series/indexes/set_with_idx.rs index 0146b6c4c3..575111534e 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/indexes/set_with_idx.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/indexes/set_with_idx.rs @@ -29,8 +29,10 @@ impl Command for SetWithIndex { "list of indices indicating where to set the value", Some('i'), ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_duplicated.rs b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_duplicated.rs index 5311e63a0b..a9d6d88656 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_duplicated.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_duplicated.rs @@ -21,8 +21,10 @@ impl Command for IsDuplicated { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_in.rs b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_in.rs index 1edb98e59f..687b5e78d2 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_in.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_in.rs @@ -23,8 +23,10 @@ impl Command for IsIn { fn signature(&self) -> Signature { Signature::build(self.name()) .required("other", SyntaxShape::Any, "right series") - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_not_null.rs b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_not_null.rs index d58bd13d21..652d9cccdb 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_not_null.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_not_null.rs @@ -20,8 +20,10 @@ impl Command for IsNotNull { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_null.rs b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_null.rs index be2d653e88..4f3f5962ff 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_null.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_null.rs @@ -20,8 +20,10 @@ impl Command for IsNull { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_unique.rs b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_unique.rs index 84ca8b737a..e903048245 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_unique.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/masks/is_unique.rs @@ -21,8 +21,10 @@ impl Command for IsUnique { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/masks/not.rs b/crates/nu-cmd-dataframe/src/dataframe/series/masks/not.rs index 990c7935dc..3bb627597d 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/masks/not.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/masks/not.rs @@ -22,8 +22,10 @@ impl Command for NotSeries { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/masks/set.rs b/crates/nu-cmd-dataframe/src/dataframe/series/masks/set.rs index 87fe242930..2d2ed72061 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/masks/set.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/masks/set.rs @@ -29,8 +29,10 @@ impl Command for SetSeries { "mask indicating insertions", Some('m'), ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/n_null.rs b/crates/nu-cmd-dataframe/src/dataframe/series/n_null.rs index bd9b2c8cd8..52f61a0a15 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/n_null.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/n_null.rs @@ -20,8 +20,10 @@ impl Command for NNull { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/n_unique.rs b/crates/nu-cmd-dataframe/src/dataframe/series/n_unique.rs index b80dac305a..657790c5a5 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/n_unique.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/n_unique.rs @@ -19,8 +19,10 @@ impl Command for NUnique { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/rolling.rs b/crates/nu-cmd-dataframe/src/dataframe/series/rolling.rs index 1f5641ccb8..9e5a568339 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/rolling.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/rolling.rs @@ -59,8 +59,10 @@ impl Command for Rolling { Signature::build(self.name()) .required("type", SyntaxShape::String, "rolling operation") .required("window", SyntaxShape::Int, "Window size for rolling") - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/shift.rs b/crates/nu-cmd-dataframe/src/dataframe/series/shift.rs index e04d607f9a..caebd173a1 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/shift.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/shift.rs @@ -30,8 +30,10 @@ impl Command for Shift { "Expression used to fill the null values (lazy df)", Some('f'), ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe or lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/concatenate.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/concatenate.rs index 4e12f867df..1152bcad63 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/concatenate.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/concatenate.rs @@ -27,8 +27,10 @@ impl Command for Concatenate { SyntaxShape::Any, "Other array with string to be concatenated", ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/contains.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/contains.rs index 48e30048ba..d82a7c526a 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/contains.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/contains.rs @@ -27,8 +27,10 @@ impl Command for Contains { SyntaxShape::String, "Regex pattern to be searched", ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/replace.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/replace.rs index 0a68761237..f0b36ddb24 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/replace.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/replace.rs @@ -34,8 +34,10 @@ impl Command for Replace { "replacing string", Some('r'), ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/replace_all.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/replace_all.rs index 9e1125568c..02532e4091 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/replace_all.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/replace_all.rs @@ -34,8 +34,10 @@ impl Command for ReplaceAll { "replacing string", Some('r'), ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/str_lengths.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/str_lengths.rs index b90c48f3bb..d33f81dc29 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/str_lengths.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/str_lengths.rs @@ -21,8 +21,10 @@ impl Command for StrLengths { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/str_slice.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/str_slice.rs index 8bfca0eed8..3c8ec85324 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/str_slice.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/str_slice.rs @@ -24,8 +24,10 @@ impl Command for StrSlice { Signature::build(self.name()) .required("start", SyntaxShape::Int, "start of slice") .named("length", SyntaxShape::Int, "optional length", Some('l')) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/strftime.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/strftime.rs index eeece66c5f..530770a608 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/strftime.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/strftime.rs @@ -23,8 +23,10 @@ impl Command for StrFTime { fn signature(&self) -> Signature { Signature::build(self.name()) .required("fmt", SyntaxShape::String, "Format rule") - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/to_lowercase.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/to_lowercase.rs index 26d0931c0d..954b4a3d95 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/to_lowercase.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/to_lowercase.rs @@ -21,8 +21,10 @@ impl Command for ToLowerCase { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/string/to_uppercase.rs b/crates/nu-cmd-dataframe/src/dataframe/series/string/to_uppercase.rs index 13c7702f84..92a2d713e2 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/string/to_uppercase.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/string/to_uppercase.rs @@ -25,8 +25,10 @@ impl Command for ToUpperCase { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/unique.rs b/crates/nu-cmd-dataframe/src/dataframe/series/unique.rs index b6794d9ab8..4f463ac2b0 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/unique.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/unique.rs @@ -40,8 +40,10 @@ impl Command for Unique { "Keep the same order as the original DataFrame (lazy df)", Some('k'), ) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe or lazyframe".into())) } diff --git a/crates/nu-cmd-dataframe/src/dataframe/series/value_counts.rs b/crates/nu-cmd-dataframe/src/dataframe/series/value_counts.rs index 6fcbe522b8..391f5130bc 100644 --- a/crates/nu-cmd-dataframe/src/dataframe/series/value_counts.rs +++ b/crates/nu-cmd-dataframe/src/dataframe/series/value_counts.rs @@ -22,8 +22,10 @@ impl Command for ValueCount { fn signature(&self) -> Signature { Signature::build(self.name()) - .input_type(Type::Custom("dataframe".into())) - .output_type(Type::Custom("dataframe".into())) + .input_output_type( + Type::Custom("dataframe".into()), + Type::Custom("dataframe".into()), + ) .category(Category::Custom("dataframe".into())) } diff --git a/crates/nu-command/src/database/commands/query_db.rs b/crates/nu-command/src/database/commands/query_db.rs index c068bc1090..a0779d33c2 100644 --- a/crates/nu-command/src/database/commands/query_db.rs +++ b/crates/nu-command/src/database/commands/query_db.rs @@ -24,8 +24,6 @@ impl Command for QueryDb { SyntaxShape::String, "SQL to execute against the database", ) - .input_type(Type::Any) - .output_type(Type::Any) .category(Category::Custom("database".into())) } diff --git a/crates/nu-command/src/database/commands/schema.rs b/crates/nu-command/src/database/commands/schema.rs index a27c8328e4..1ce80294f8 100644 --- a/crates/nu-command/src/database/commands/schema.rs +++ b/crates/nu-command/src/database/commands/schema.rs @@ -17,8 +17,6 @@ impl Command for SchemaDb { fn signature(&self) -> Signature { Signature::build(self.name()) .input_output_types(vec![(Type::Any, Type::Any)]) - .input_type(Type::Any) - .output_type(Type::Any) .category(Category::Custom("database".into())) } diff --git a/crates/nu-command/src/filters/lines.rs b/crates/nu-command/src/filters/lines.rs index 61bddcab70..31fbcf2c25 100644 --- a/crates/nu-command/src/filters/lines.rs +++ b/crates/nu-command/src/filters/lines.rs @@ -23,7 +23,7 @@ impl Command for Lines { fn signature(&self) -> nu_protocol::Signature { Signature::build("lines") - .input_output_types(vec![(Type::String, Type::List(Box::new(Type::String)))]) + .input_output_types(vec![(Type::Any, Type::List(Box::new(Type::String)))]) .switch("skip-empty", "skip empty lines", Some('s')) .category(Category::Filters) } diff --git a/crates/nu-command/src/strings/encode_decode/encode_base64.rs b/crates/nu-command/src/strings/encode_decode/encode_base64.rs index 65e390aa58..6ba4d5b59a 100644 --- a/crates/nu-command/src/strings/encode_decode/encode_base64.rs +++ b/crates/nu-command/src/strings/encode_decode/encode_base64.rs @@ -31,7 +31,6 @@ impl Command for EncodeBase64 { SyntaxShape::CellPath, "For a data structure input, encode data at the given cell paths", ) - .output_type(Type::String) .category(Category::Hash) } diff --git a/crates/nu-command/src/strings/encode_decode/encode_hex.rs b/crates/nu-command/src/strings/encode_decode/encode_hex.rs index cb9f350bc2..d4974ea83f 100644 --- a/crates/nu-command/src/strings/encode_decode/encode_hex.rs +++ b/crates/nu-command/src/strings/encode_decode/encode_hex.rs @@ -22,7 +22,6 @@ impl Command for EncodeHex { SyntaxShape::CellPath, "For a data structure input, encode data at the given cell paths", ) - .output_type(Type::String) .category(Category::Formats) } diff --git a/crates/nu-parser/src/parse_keywords.rs b/crates/nu-parser/src/parse_keywords.rs index eeb8611263..19a1e64495 100644 --- a/crates/nu-parser/src/parse_keywords.rs +++ b/crates/nu-parser/src/parse_keywords.rs @@ -1,4 +1,4 @@ -use crate::parser_path::ParserPath; +use crate::{parser_path::ParserPath, type_check::type_compatible}; use itertools::Itertools; use log::trace; use nu_path::canonicalize_with; @@ -235,7 +235,7 @@ pub fn parse_for(working_set: &mut StateWorkingSet, spans: &[Span]) -> Expressio // Parsing the spans and checking that they match the register signature // Using a parsed call makes more sense than checking for how many spans are in the call // Also, by creating a call, it can be checked if it matches the declaration signature - let (call, call_span) = match working_set.find_decl(b"for", &Type::Any) { + let (call, call_span) = match working_set.find_decl(b"for", &Type::Nothing) { None => { working_set.error(ParseError::UnknownState( "internal error: for declaration not found".into(), @@ -290,9 +290,21 @@ pub fn parse_for(working_set: &mut StateWorkingSet, spans: &[Span]) -> Expressio // All positional arguments must be in the call positional vector by this point let var_decl = call.positional_nth(0).expect("for call already checked"); + let iteration_expr = call.positional_nth(1).expect("for call already checked"); let block = call.positional_nth(2).expect("for call already checked"); + let iteration_expr_ty = iteration_expr.ty.clone(); + + // Figure out the type of the variable the `for` uses for iteration + let var_type = match iteration_expr_ty { + Type::List(x) => *x, + Type::Table(x) => Type::Record(x), + x => x, + }; + if let (Some(var_id), Some(block_id)) = (&var_decl.as_var(), block.as_block()) { + working_set.set_variable_type(*var_id, var_type.clone()); + let block = working_set.get_block_mut(block_id); block.signature.required_positional.insert( @@ -300,7 +312,7 @@ pub fn parse_for(working_set: &mut StateWorkingSet, spans: &[Span]) -> Expressio PositionalArg { name: String::new(), desc: String::new(), - shape: SyntaxShape::Any, + shape: var_type.to_shape(), var_id: Some(*var_id), default_value: None, }, @@ -310,7 +322,7 @@ pub fn parse_for(working_set: &mut StateWorkingSet, spans: &[Span]) -> Expressio Expression { expr: Expr::Call(call), span: call_span, - ty: Type::Any, + ty: Type::Nothing, custom_completion: None, } } @@ -347,7 +359,7 @@ pub fn parse_def( // Parsing the spans and checking that they match the register signature // Using a parsed call makes more sense than checking for how many spans are in the call // Also, by creating a call, it can be checked if it matches the declaration signature - let (call, call_span) = match working_set.find_decl(&def_call, &Type::Any) { + let (call, call_span) = match working_set.find_decl(&def_call, &Type::Nothing) { None => { working_set.error(ParseError::UnknownState( "internal error: def declaration not found".into(), @@ -391,12 +403,15 @@ pub fn parse_def( expr: Expr::Block(block_id), .. } + | Expression { + expr: Expr::Closure(block_id), + .. + } | Expression { expr: Expr::RowCondition(block_id), .. } => { let block = working_set.get_block_mut(*block_id); - block.signature = Box::new(sig.clone()); } _ => {} @@ -469,6 +484,20 @@ pub fn parse_def( block.recursive = Some(calls_itself); block.signature = signature; block.redirect_env = def_call == b"def-env"; + + // Sadly we can't use this here as the inference would have to happen before + // all the definitions had been fully parsed. + + // infer the return type based on the output of the block + // let block = working_set.get_block(block_id); + + // let input_type = block.input_type(working_set); + // let output_type = block.output_type(); + // block.signature.input_output_types = vec![(input_type, output_type)]; + block + .signature + .input_output_types + .push((Type::Any, Type::Any)); } else { working_set.error(ParseError::InternalError( "Predeclaration failed to add declaration".into(), @@ -519,7 +548,7 @@ pub fn parse_extern( // Parsing the spans and checking that they match the register signature // Using a parsed call makes more sense than checking for how many spans are in the call // Also, by creating a call, it can be checked if it matches the declaration signature - let (call, call_span) = match working_set.find_decl(&extern_call, &Type::Any) { + let (call, call_span) = match working_set.find_decl(&extern_call, &Type::Nothing) { None => { working_set.error(ParseError::UnknownState( "internal error: def declaration not found".into(), @@ -710,7 +739,7 @@ pub fn parse_alias( return Pipeline::from_vec(vec![garbage(*span)]); } - if let Some(decl_id) = working_set.find_decl(b"alias", &Type::Any) { + if let Some(decl_id) = working_set.find_decl(b"alias", &Type::Nothing) { let (command_spans, rest_spans) = spans.split_at(split_id); let original_starting_error_count = working_set.parse_errors.len(); @@ -912,7 +941,7 @@ pub fn parse_export_in_block( b"export".to_vec() }; - if let Some(decl_id) = working_set.find_decl(&full_name, &Type::Any) { + if let Some(decl_id) = working_set.find_decl(&full_name, &Type::Nothing) { let ParsedInternalCall { call, output, .. } = parse_internal_call( working_set, if full_name == b"export" { @@ -1006,7 +1035,7 @@ pub fn parse_export_in_module( return (garbage_pipeline(spans), vec![]); }; - let export_decl_id = if let Some(id) = working_set.find_decl(b"export", &Type::Any) { + let export_decl_id = if let Some(id) = working_set.find_decl(b"export", &Type::Nothing) { id } else { working_set.error(ParseError::InternalError( @@ -1036,7 +1065,7 @@ pub fn parse_export_in_module( let pipeline = parse_def(working_set, &lite_command, Some(module_name)); let export_def_decl_id = - if let Some(id) = working_set.find_decl(b"export def", &Type::Any) { + if let Some(id) = working_set.find_decl(b"export def", &Type::Nothing) { id } else { working_set.error(ParseError::InternalError( @@ -1072,7 +1101,7 @@ pub fn parse_export_in_module( let decl_name = working_set.get_span_contents(*decl_name_span); let decl_name = trim_quotes(decl_name); - if let Some(decl_id) = working_set.find_decl(decl_name, &Type::Any) { + if let Some(decl_id) = working_set.find_decl(decl_name, &Type::Nothing) { result.push(Exportable::Decl { name: decl_name.to_vec(), id: decl_id, @@ -1095,7 +1124,7 @@ pub fn parse_export_in_module( let pipeline = parse_def(working_set, &lite_command, Some(module_name)); let export_def_decl_id = - if let Some(id) = working_set.find_decl(b"export def-env", &Type::Any) { + if let Some(id) = working_set.find_decl(b"export def-env", &Type::Nothing) { id } else { working_set.error(ParseError::InternalError( @@ -1133,7 +1162,7 @@ pub fn parse_export_in_module( }; let decl_name = trim_quotes(decl_name); - if let Some(decl_id) = working_set.find_decl(decl_name, &Type::Any) { + if let Some(decl_id) = working_set.find_decl(decl_name, &Type::Nothing) { result.push(Exportable::Decl { name: decl_name.to_vec(), id: decl_id, @@ -1155,7 +1184,7 @@ pub fn parse_export_in_module( let pipeline = parse_extern(working_set, &lite_command, Some(module_name)); let export_def_decl_id = - if let Some(id) = working_set.find_decl(b"export extern", &Type::Any) { + if let Some(id) = working_set.find_decl(b"export extern", &Type::Nothing) { id } else { working_set.error(ParseError::InternalError( @@ -1193,7 +1222,7 @@ pub fn parse_export_in_module( }; let decl_name = trim_quotes(decl_name); - if let Some(decl_id) = working_set.find_decl(decl_name, &Type::Any) { + if let Some(decl_id) = working_set.find_decl(decl_name, &Type::Nothing) { result.push(Exportable::Decl { name: decl_name.to_vec(), id: decl_id, @@ -1215,7 +1244,7 @@ pub fn parse_export_in_module( let pipeline = parse_alias(working_set, &lite_command, Some(module_name)); let export_alias_decl_id = - if let Some(id) = working_set.find_decl(b"export alias", &Type::Any) { + if let Some(id) = working_set.find_decl(b"export alias", &Type::Nothing) { id } else { working_set.error(ParseError::InternalError( @@ -1253,7 +1282,7 @@ pub fn parse_export_in_module( }; let alias_name = trim_quotes(alias_name); - if let Some(alias_id) = working_set.find_decl(alias_name, &Type::Any) { + if let Some(alias_id) = working_set.find_decl(alias_name, &Type::Nothing) { result.push(Exportable::Decl { name: alias_name.to_vec(), id: alias_id, @@ -1275,7 +1304,7 @@ pub fn parse_export_in_module( let (pipeline, exportables) = parse_use(working_set, &lite_command.parts); let export_use_decl_id = - if let Some(id) = working_set.find_decl(b"export use", &Type::Any) { + if let Some(id) = working_set.find_decl(b"export use", &Type::Nothing) { id } else { working_set.error(ParseError::InternalError( @@ -1312,7 +1341,7 @@ pub fn parse_export_in_module( parse_module(working_set, lite_command, Some(module_name)); let export_module_decl_id = - if let Some(id) = working_set.find_decl(b"export module", &Type::Any) { + if let Some(id) = working_set.find_decl(b"export module", &Type::Nothing) { id } else { working_set.error(ParseError::InternalError( @@ -1417,7 +1446,7 @@ pub fn parse_export_env( return (garbage_pipeline(spans), None); } - let call = match working_set.find_decl(b"export-env", &Type::Any) { + let call = match working_set.find_decl(b"export-env", &Type::Nothing) { Some(decl_id) => { let ParsedInternalCall { call, output } = parse_internal_call(working_set, spans[0], &[spans[1]], decl_id); @@ -1929,7 +1958,7 @@ pub fn parse_module( 1 }; - let (call, call_span) = match working_set.find_decl(b"module", &Type::Any) { + let (call, call_span) = match working_set.find_decl(b"module", &Type::Nothing) { Some(decl_id) => { let (command_spans, rest_spans) = spans.split_at(split_id); @@ -2070,7 +2099,7 @@ pub fn parse_module( }; let module_decl_id = working_set - .find_decl(b"module", &Type::Any) + .find_decl(b"module", &Type::Nothing) .expect("internal error: missing module command"); let call = Box::new(Call { @@ -2121,7 +2150,7 @@ pub fn parse_use(working_set: &mut StateWorkingSet, spans: &[Span]) -> (Pipeline return (garbage_pipeline(spans), vec![]); } - let (call, call_span, args_spans) = match working_set.find_decl(b"use", &Type::Any) { + let (call, call_span, args_spans) = match working_set.find_decl(b"use", &Type::Nothing) { Some(decl_id) => { let (command_spans, rest_spans) = spans.split_at(split_id); @@ -2277,7 +2306,7 @@ pub fn parse_hide(working_set: &mut StateWorkingSet, spans: &[Span]) -> Pipeline return garbage_pipeline(spans); } - let (call, args_spans) = match working_set.find_decl(b"hide", &Type::Any) { + let (call, args_spans) = match working_set.find_decl(b"hide", &Type::Nothing) { Some(decl_id) => { let ParsedInternalCall { call, output } = parse_internal_call(working_set, spans[0], &spans[1..], decl_id); @@ -2336,7 +2365,7 @@ pub fn parse_hide(working_set: &mut StateWorkingSet, spans: &[Span]) -> Pipeline (true, working_set.get_module(module_id).clone()) } else if import_pattern.members.is_empty() { // The pattern head can be: - if let Some(id) = working_set.find_decl(&import_pattern.head.name, &Type::Any) { + if let Some(id) = working_set.find_decl(&import_pattern.head.name, &Type::Nothing) { // a custom command, let mut module = Module::new(b"tmp".to_vec()); module.add_decl(import_pattern.head.name.clone(), id); @@ -2767,17 +2796,19 @@ pub fn parse_overlay_hide(working_set: &mut StateWorkingSet, call: Box) -> } pub fn parse_let_or_const(working_set: &mut StateWorkingSet, spans: &[Span]) -> Pipeline { + trace!("parsing: let"); let name = working_set.get_span_contents(spans[0]); if name == b"let" || name == b"const" { let is_const = &name == b"const"; - if let Some(span) = check_name(working_set, spans) { - return Pipeline::from_vec(vec![garbage(*span)]); - } + // JT: Disabling check_name because it doesn't work with optional types in the declaration + // if let Some(span) = check_name(working_set, spans) { + // return Pipeline::from_vec(vec![garbage(*span)]); + // } if let Some(decl_id) = - working_set.find_decl(if is_const { b"const" } else { b"let" }, &Type::Any) + working_set.find_decl(if is_const { b"const" } else { b"let" }, &Type::Nothing) { let cmd = working_set.get_decl(decl_id); let call_signature = cmd.signature().call_signature(); @@ -2805,7 +2836,8 @@ pub fn parse_let_or_const(working_set: &mut StateWorkingSet, spans: &[Span]) -> } let mut idx = 0; - let lvalue = parse_var_with_opt_type( + + let (lvalue, explicit_type) = parse_var_with_opt_type( working_set, &spans[1..(span.0)], &mut idx, @@ -2824,8 +2856,20 @@ pub fn parse_let_or_const(working_set: &mut StateWorkingSet, spans: &[Span]) -> let var_id = lvalue.as_var(); let rhs_type = rvalue.ty.clone(); + if let Some(explicit_type) = &explicit_type { + if !type_compatible(explicit_type, &rhs_type) { + working_set.error(ParseError::TypeMismatch( + explicit_type.clone(), + rhs_type.clone(), + nu_protocol::span(&spans[(span.0 + 1)..]), + )); + } + } + if let Some(var_id) = var_id { - working_set.set_variable_type(var_id, rhs_type); + if explicit_type.is_none() { + working_set.set_variable_type(var_id, rhs_type); + } if is_const { match eval_constant(working_set, &rvalue) { @@ -2867,6 +2911,11 @@ pub fn parse_let_or_const(working_set: &mut StateWorkingSet, spans: &[Span]) -> ty: output, custom_completion: None, }]); + } else { + working_set.error(ParseError::UnknownState( + "internal error: let or const statements not found in core language".into(), + span(spans), + )) } } @@ -2882,11 +2931,11 @@ pub fn parse_mut(working_set: &mut StateWorkingSet, spans: &[Span]) -> Pipeline let name = working_set.get_span_contents(spans[0]); if name == b"mut" { - if let Some(span) = check_name(working_set, spans) { - return Pipeline::from_vec(vec![garbage(*span)]); - } + // if let Some(span) = check_name(working_set, spans) { + // return Pipeline::from_vec(vec![garbage(*span)]); + // } - if let Some(decl_id) = working_set.find_decl(b"mut", &Type::Any) { + if let Some(decl_id) = working_set.find_decl(b"mut", &Type::Nothing) { let cmd = working_set.get_decl(decl_id); let call_signature = cmd.signature().call_signature(); @@ -2913,7 +2962,7 @@ pub fn parse_mut(working_set: &mut StateWorkingSet, spans: &[Span]) -> Pipeline } let mut idx = 0; - let lvalue = parse_var_with_opt_type( + let (lvalue, explicit_type) = parse_var_with_opt_type( working_set, &spans[1..(span.0)], &mut idx, @@ -2932,8 +2981,20 @@ pub fn parse_mut(working_set: &mut StateWorkingSet, spans: &[Span]) -> Pipeline let var_id = lvalue.as_var(); let rhs_type = rvalue.ty.clone(); + if let Some(explicit_type) = &explicit_type { + if &rhs_type != explicit_type && explicit_type != &Type::Any { + working_set.error(ParseError::TypeMismatch( + explicit_type.clone(), + rhs_type.clone(), + rvalue.span, + )); + } + } + if let Some(var_id) = var_id { - working_set.set_variable_type(var_id, rhs_type); + if explicit_type.is_none() { + working_set.set_variable_type(var_id, rhs_type); + } } let call = Box::new(Call { @@ -2982,7 +3043,7 @@ pub fn parse_source(working_set: &mut StateWorkingSet, spans: &[Span]) -> Pipeli if name == b"source" || name == b"source-env" { let scoped = name == b"source-env"; - if let Some(decl_id) = working_set.find_decl(name, &Type::Any) { + if let Some(decl_id) = working_set.find_decl(name, &Type::Nothing) { let cwd = working_set.get_cwd(); // Is this the right call to be using here? @@ -3113,7 +3174,7 @@ pub fn parse_where_expr(working_set: &mut StateWorkingSet, spans: &[Span]) -> Ex return garbage(span(spans)); } - let call = match working_set.find_decl(b"where", &Type::Any) { + let call = match working_set.find_decl(b"where", &Type::List(Box::new(Type::Any))) { Some(decl_id) => { let ParsedInternalCall { call, output } = parse_internal_call(working_set, spans[0], &spans[1..], decl_id); @@ -3176,7 +3237,7 @@ pub fn parse_register(working_set: &mut StateWorkingSet, spans: &[Span]) -> Pipe // Parsing the spans and checking that they match the register signature // Using a parsed call makes more sense than checking for how many spans are in the call // Also, by creating a call, it can be checked if it matches the declaration signature - let (call, call_span) = match working_set.find_decl(b"register", &Type::Any) { + let (call, call_span) = match working_set.find_decl(b"register", &Type::Nothing) { None => { working_set.error(ParseError::UnknownState( "internal error: Register declaration not found".into(), diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 8edc4ae677..13d59c5359 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -607,7 +607,7 @@ pub fn parse_multispan_value( SyntaxShape::VarWithOptType => { trace!("parsing: var with opt type"); - parse_var_with_opt_type(working_set, spans, spans_idx, false) + parse_var_with_opt_type(working_set, spans, spans_idx, false).0 } SyntaxShape::RowCondition => { trace!("parsing: row condition"); @@ -779,7 +779,7 @@ pub fn parse_internal_call( let decl = working_set.get_decl(decl_id); let signature = decl.signature(); - let output = signature.output_type.clone(); + let output = signature.get_output_type(); if decl.is_builtin() { attach_parser_info_builtin(working_set, decl.name(), &mut call); @@ -1172,6 +1172,7 @@ pub fn parse_call( } pub fn parse_binary(working_set: &mut StateWorkingSet, span: Span) -> Expression { + trace!("parsing: binary"); let contents = working_set.get_span_contents(span); if contents.starts_with(b"0x[") { parse_binary_with_base(working_set, span, 16, 2, b"0x[", b"]") @@ -2007,25 +2008,7 @@ pub fn parse_full_cell_path( .type_scope .add_type(working_set.type_scope.get_last_output()); - let ty = output - .pipelines - .last() - .and_then(|Pipeline { elements, .. }| elements.last()) - .map(|element| match element { - PipelineElement::Expression(_, expr) - if matches!( - expr, - Expression { - expr: Expr::BinaryOp(..), - .. - } - ) => - { - expr.ty.clone() - } - _ => working_set.type_scope.get_last_output(), - }) - .unwrap_or_else(|| working_set.type_scope.get_last_output()); + let ty = output.output_type(); let block_id = working_set.add_block(output); tokens.next(); @@ -3081,7 +3064,7 @@ pub fn parse_var_with_opt_type( spans: &[Span], spans_idx: &mut usize, mutable: bool, -) -> Expression { +) -> (Expression, Option) { let bytes = working_set.get_span_contents(spans[*spans_idx]).to_vec(); if bytes.contains(&b' ') @@ -3090,7 +3073,7 @@ pub fn parse_var_with_opt_type( || bytes.contains(&b'`') { working_set.error(ParseError::VariableNotValid(spans[*spans_idx])); - return garbage(spans[*spans_idx]); + return (garbage(spans[*spans_idx]), None); } if bytes.ends_with(b":") { @@ -3108,17 +3091,20 @@ pub fn parse_var_with_opt_type( "valid variable name", spans[*spans_idx], )); - return garbage(spans[*spans_idx]); + return (garbage(spans[*spans_idx]), None); } let id = working_set.add_variable(var_name, spans[*spans_idx - 1], ty.clone(), mutable); - Expression { - expr: Expr::VarDecl(id), - span: span(&spans[*spans_idx - 1..*spans_idx + 1]), - ty, - custom_completion: None, - } + ( + Expression { + expr: Expr::VarDecl(id), + span: span(&spans[*spans_idx - 1..*spans_idx + 1]), + ty: ty.clone(), + custom_completion: None, + }, + Some(ty), + ) } else { let var_name = bytes[0..(bytes.len() - 1)].to_vec(); @@ -3127,18 +3113,21 @@ pub fn parse_var_with_opt_type( "valid variable name", spans[*spans_idx], )); - return garbage(spans[*spans_idx]); + return (garbage(spans[*spans_idx]), None); } let id = working_set.add_variable(var_name, spans[*spans_idx], Type::Any, mutable); working_set.error(ParseError::MissingType(spans[*spans_idx])); - Expression { - expr: Expr::VarDecl(id), - span: spans[*spans_idx], - ty: Type::Any, - custom_completion: None, - } + ( + Expression { + expr: Expr::VarDecl(id), + span: spans[*spans_idx], + ty: Type::Any, + custom_completion: None, + }, + None, + ) } } else { let var_name = bytes; @@ -3148,7 +3137,7 @@ pub fn parse_var_with_opt_type( "valid variable name", spans[*spans_idx], )); - return garbage(spans[*spans_idx]); + return (garbage(spans[*spans_idx]), None); } let id = working_set.add_variable( @@ -3158,12 +3147,15 @@ pub fn parse_var_with_opt_type( mutable, ); - Expression { - expr: Expr::VarDecl(id), - span: span(&spans[*spans_idx..*spans_idx + 1]), - ty: Type::Any, - custom_completion: None, - } + ( + Expression { + expr: Expr::VarDecl(id), + span: span(&spans[*spans_idx..*spans_idx + 1]), + ty: Type::Any, + custom_completion: None, + }, + None, + ) } } @@ -5088,11 +5080,13 @@ pub fn parse_builtin_commands( lite_command: &LiteCommand, is_subexpression: bool, ) -> Pipeline { + trace!("parsing: builtin commands"); if !is_math_expression_like(working_set, lite_command.parts[0]) && !is_unaliasable_parser_keyword(working_set, &lite_command.parts) { + trace!("parsing: not math expression or unaliasable parser keyword"); let name = working_set.get_span_contents(lite_command.parts[0]); - if let Some(decl_id) = working_set.find_decl(name, &Type::Any) { + if let Some(decl_id) = working_set.find_decl(name, &Type::Nothing) { let cmd = working_set.get_decl(decl_id); if cmd.is_alias() { // Parse keywords that can be aliased. Note that we check for "unaliasable" keywords @@ -5122,6 +5116,7 @@ pub fn parse_builtin_commands( } } + trace!("parsing: checking for keywords"); let name = working_set.get_span_contents(lite_command.parts[0]); match name { @@ -5347,9 +5342,9 @@ pub fn parse_block( parse_builtin_commands(working_set, command, is_subexpression); if idx == 0 { - if let Some(let_decl_id) = working_set.find_decl(b"let", &Type::Any) { + if let Some(let_decl_id) = working_set.find_decl(b"let", &Type::Nothing) { if let Some(let_env_decl_id) = - working_set.find_decl(b"let-env", &Type::Any) + working_set.find_decl(b"let-env", &Type::Nothing) { for element in pipeline.elements.iter_mut() { if let PipelineElement::Expression( @@ -5823,7 +5818,7 @@ fn wrap_element_with_collect( fn wrap_expr_with_collect(working_set: &mut StateWorkingSet, expr: &Expression) -> Expression { let span = expr.span; - if let Some(decl_id) = working_set.find_decl(b"collect", &Type::Any) { + if let Some(decl_id) = working_set.find_decl(b"collect", &Type::List(Box::new(Type::Any))) { let mut output = vec![]; let var_id = IN_VARIABLE_ID; diff --git a/crates/nu-parser/src/type_check.rs b/crates/nu-parser/src/type_check.rs index 3ad88e70e5..aa5ffce1b3 100644 --- a/crates/nu-parser/src/type_check.rs +++ b/crates/nu-parser/src/type_check.rs @@ -22,8 +22,11 @@ pub fn type_compatible(lhs: &Type, rhs: &Type) -> bool { match (lhs, rhs) { (Type::List(c), Type::List(d)) => type_compatible(c, d), + (Type::List(c), Type::Table(_)) => matches!(**c, Type::Any), (Type::Number, Type::Int) => true, + (Type::Int, Type::Number) => true, (Type::Number, Type::Float) => true, + (Type::Float, Type::Number) => true, (Type::Closure, Type::Block) => true, (Type::Any, _) => true, (_, Type::Any) => true, @@ -47,6 +50,11 @@ pub fn math_result_type( (Type::Float, Type::Int) => (Type::Float, None), (Type::Int, Type::Float) => (Type::Float, None), (Type::Float, Type::Float) => (Type::Float, None), + (Type::Number, Type::Number) => (Type::Number, None), + (Type::Number, Type::Int) => (Type::Number, None), + (Type::Int, Type::Number) => (Type::Number, None), + (Type::Number, Type::Float) => (Type::Number, None), + (Type::Float, Type::Number) => (Type::Number, None), (Type::String, Type::String) => (Type::String, None), (Type::Date, Type::Duration) => (Type::Date, None), (Type::Duration, Type::Duration) => (Type::Duration, None), @@ -143,6 +151,11 @@ pub fn math_result_type( (Type::Float, Type::Int) => (Type::Float, None), (Type::Int, Type::Float) => (Type::Float, None), (Type::Float, Type::Float) => (Type::Float, None), + (Type::Number, Type::Number) => (Type::Number, None), + (Type::Number, Type::Int) => (Type::Number, None), + (Type::Int, Type::Number) => (Type::Number, None), + (Type::Number, Type::Float) => (Type::Number, None), + (Type::Float, Type::Number) => (Type::Number, None), (Type::Date, Type::Date) => (Type::Duration, None), (Type::Date, Type::Duration) => (Type::Date, None), (Type::Duration, Type::Duration) => (Type::Duration, None), @@ -185,6 +198,11 @@ pub fn math_result_type( (Type::Float, Type::Int) => (Type::Float, None), (Type::Int, Type::Float) => (Type::Float, None), (Type::Float, Type::Float) => (Type::Float, None), + (Type::Number, Type::Number) => (Type::Number, None), + (Type::Number, Type::Int) => (Type::Number, None), + (Type::Int, Type::Number) => (Type::Number, None), + (Type::Number, Type::Float) => (Type::Number, None), + (Type::Float, Type::Number) => (Type::Number, None), (Type::Filesize, Type::Int) => (Type::Filesize, None), (Type::Int, Type::Filesize) => (Type::Filesize, None), (Type::Filesize, Type::Float) => (Type::Filesize, None), @@ -241,6 +259,11 @@ pub fn math_result_type( (Type::Float, Type::Int) => (Type::Float, None), (Type::Int, Type::Float) => (Type::Float, None), (Type::Float, Type::Float) => (Type::Float, None), + (Type::Number, Type::Number) => (Type::Number, None), + (Type::Number, Type::Int) => (Type::Number, None), + (Type::Int, Type::Number) => (Type::Number, None), + (Type::Number, Type::Float) => (Type::Number, None), + (Type::Float, Type::Number) => (Type::Number, None), (Type::Custom(a), Type::Custom(b)) if a == b => (Type::Custom(a.to_string()), None), (Type::Custom(a), _) => (Type::Custom(a.to_string()), None), @@ -280,6 +303,11 @@ pub fn math_result_type( (Type::Float, Type::Int) => (Type::Float, None), (Type::Int, Type::Float) => (Type::Float, None), (Type::Float, Type::Float) => (Type::Float, None), + (Type::Number, Type::Number) => (Type::Number, None), + (Type::Number, Type::Int) => (Type::Number, None), + (Type::Int, Type::Number) => (Type::Number, None), + (Type::Number, Type::Float) => (Type::Number, None), + (Type::Float, Type::Number) => (Type::Number, None), (Type::Filesize, Type::Filesize) => (Type::Float, None), (Type::Filesize, Type::Int) => (Type::Filesize, None), (Type::Filesize, Type::Float) => (Type::Filesize, None), @@ -324,6 +352,11 @@ pub fn math_result_type( (Type::Float, Type::Int) => (Type::Int, None), (Type::Int, Type::Float) => (Type::Int, None), (Type::Float, Type::Float) => (Type::Int, None), + (Type::Number, Type::Number) => (Type::Number, None), + (Type::Number, Type::Int) => (Type::Number, None), + (Type::Int, Type::Number) => (Type::Number, None), + (Type::Number, Type::Float) => (Type::Number, None), + (Type::Float, Type::Number) => (Type::Number, None), (Type::Filesize, Type::Filesize) => (Type::Int, None), (Type::Filesize, Type::Int) => (Type::Filesize, None), (Type::Filesize, Type::Float) => (Type::Filesize, None), @@ -410,7 +443,13 @@ pub fn math_result_type( (Type::Float, Type::Int) => (Type::Bool, None), (Type::Int, Type::Float) => (Type::Bool, None), (Type::Float, Type::Float) => (Type::Bool, None), + (Type::Number, Type::Number) => (Type::Bool, None), + (Type::Number, Type::Int) => (Type::Bool, None), + (Type::Int, Type::Number) => (Type::Bool, None), + (Type::Number, Type::Float) => (Type::Bool, None), + (Type::Float, Type::Number) => (Type::Bool, None), (Type::Duration, Type::Duration) => (Type::Bool, None), + (Type::Date, Type::Date) => (Type::Bool, None), (Type::Filesize, Type::Filesize) => (Type::Bool, None), (Type::Custom(a), Type::Custom(b)) if a == b => (Type::Custom(a.to_string()), None), @@ -453,7 +492,13 @@ pub fn math_result_type( (Type::Float, Type::Int) => (Type::Bool, None), (Type::Int, Type::Float) => (Type::Bool, None), (Type::Float, Type::Float) => (Type::Bool, None), + (Type::Number, Type::Number) => (Type::Bool, None), + (Type::Number, Type::Int) => (Type::Bool, None), + (Type::Int, Type::Number) => (Type::Bool, None), + (Type::Number, Type::Float) => (Type::Bool, None), + (Type::Float, Type::Number) => (Type::Bool, None), (Type::Duration, Type::Duration) => (Type::Bool, None), + (Type::Date, Type::Date) => (Type::Bool, None), (Type::Filesize, Type::Filesize) => (Type::Bool, None), (Type::Custom(a), Type::Custom(b)) if a == b => (Type::Custom(a.to_string()), None), @@ -496,7 +541,13 @@ pub fn math_result_type( (Type::Float, Type::Int) => (Type::Bool, None), (Type::Int, Type::Float) => (Type::Bool, None), (Type::Float, Type::Float) => (Type::Bool, None), + (Type::Number, Type::Number) => (Type::Bool, None), + (Type::Number, Type::Int) => (Type::Bool, None), + (Type::Int, Type::Number) => (Type::Bool, None), + (Type::Number, Type::Float) => (Type::Bool, None), + (Type::Float, Type::Number) => (Type::Bool, None), (Type::Duration, Type::Duration) => (Type::Bool, None), + (Type::Date, Type::Date) => (Type::Bool, None), (Type::Filesize, Type::Filesize) => (Type::Bool, None), (Type::Custom(a), Type::Custom(b)) if a == b => (Type::Custom(a.to_string()), None), @@ -539,7 +590,13 @@ pub fn math_result_type( (Type::Float, Type::Int) => (Type::Bool, None), (Type::Int, Type::Float) => (Type::Bool, None), (Type::Float, Type::Float) => (Type::Bool, None), + (Type::Number, Type::Number) => (Type::Bool, None), + (Type::Number, Type::Int) => (Type::Bool, None), + (Type::Int, Type::Number) => (Type::Bool, None), + (Type::Number, Type::Float) => (Type::Bool, None), + (Type::Float, Type::Number) => (Type::Bool, None), (Type::Duration, Type::Duration) => (Type::Bool, None), + (Type::Date, Type::Date) => (Type::Bool, None), (Type::Filesize, Type::Filesize) => (Type::Bool, None), (Type::Custom(a), Type::Custom(b)) if a == b => (Type::Custom(a.to_string()), None), @@ -731,7 +788,7 @@ pub fn math_result_type( }, Operator::Comparison(Comparison::In) => match (&lhs.ty, &rhs.ty) { (t, Type::List(u)) if type_compatible(t, u) => (Type::Bool, None), - (Type::Int | Type::Float, Type::Range) => (Type::Bool, None), + (Type::Int | Type::Float | Type::Number, Type::Range) => (Type::Bool, None), (Type::String, Type::String) => (Type::Bool, None), (Type::String, Type::Record(_)) => (Type::Bool, None), @@ -769,7 +826,7 @@ pub fn math_result_type( }, Operator::Comparison(Comparison::NotIn) => match (&lhs.ty, &rhs.ty) { (t, Type::List(u)) if type_compatible(t, u) => (Type::Bool, None), - (Type::Int | Type::Float, Type::Range) => (Type::Bool, None), + (Type::Int | Type::Float | Type::Number, Type::Range) => (Type::Bool, None), (Type::String, Type::String) => (Type::Bool, None), (Type::String, Type::Record(_)) => (Type::Bool, None), diff --git a/crates/nu-parser/tests/test_parser.rs b/crates/nu-parser/tests/test_parser.rs index 2659460bba..f67f8c04f6 100644 --- a/crates/nu-parser/tests/test_parser.rs +++ b/crates/nu-parser/tests/test_parser.rs @@ -1361,8 +1361,7 @@ mod input_types { fn signature(&self) -> nu_protocol::Signature { Signature::build(self.name()) - .input_type(Type::Any) - .output_type(Type::Custom("custom".into())) + .input_output_type(Type::Any, Type::Custom("custom".into())) .category(Category::Custom("custom".into())) } @@ -1393,8 +1392,7 @@ mod input_types { Signature::build(self.name()) .required("column", SyntaxShape::String, "column name") .required("other", SyntaxShape::String, "other value") - .input_type(Type::Custom("custom".into())) - .output_type(Type::Custom("custom".into())) + .input_output_type(Type::Custom("custom".into()), Type::Custom("custom".into())) .category(Category::Custom("custom".into())) } @@ -1424,7 +1422,7 @@ mod input_types { fn signature(&self) -> nu_protocol::Signature { Signature::build(self.name()) .required("operation", SyntaxShape::String, "operation") - .input_type(Type::Custom("custom".into())) + .input_output_type(Type::Custom("custom".into()), Type::Custom("custom".into())) .category(Category::Custom("custom".into())) } @@ -1481,8 +1479,7 @@ mod input_types { fn signature(&self) -> nu_protocol::Signature { Signature::build(self.name()) .rest("operation", SyntaxShape::Any, "operation") - .input_type(Type::Custom("custom".into())) - .output_type(Type::Custom("custom".into())) + .input_output_type(Type::Custom("custom".into()), Type::Custom("custom".into())) .category(Category::Custom("custom".into())) } @@ -1511,8 +1508,7 @@ mod input_types { fn signature(&self) -> nu_protocol::Signature { Signature::build(self.name()) - .input_type(Type::Custom("custom".into())) - .output_type(Type::Custom("custom".into())) + .input_output_type(Type::Custom("custom".into()), Type::Custom("custom".into())) .category(Category::Custom("custom".into())) } @@ -1619,7 +1615,7 @@ mod input_types { }, ) => { let expected_id = working_set - .find_decl(b"ls", &Type::Any) + .find_decl(b"ls", &Type::Nothing) .expect("Error merging delta"); assert_eq!(call.decl_id, expected_id) } @@ -1789,7 +1785,7 @@ mod input_types { .. }, ) => { - let expected_id = working_set.find_decl(b"ls", &Type::Any).unwrap(); + let expected_id = working_set.find_decl(b"ls", &Type::Nothing).unwrap(); assert_eq!(call.decl_id, expected_id) } _ => panic!("Expected expression Call not found"), diff --git a/crates/nu-plugin/src/plugin/mod.rs b/crates/nu-plugin/src/plugin/mod.rs index 809b4975b0..5eefb42903 100644 --- a/crates/nu-plugin/src/plugin/mod.rs +++ b/crates/nu-plugin/src/plugin/mod.rs @@ -203,7 +203,7 @@ pub fn get_signature( /// impl Plugin for HelloPlugin { /// fn signature(&self) -> Vec { /// let sig = PluginSignature::build("hello") -/// .output_type(Type::String); +/// .input_output_type(Type::Nothing, Type::String); /// /// vec![sig] /// } diff --git a/crates/nu-protocol/src/ast/block.rs b/crates/nu-protocol/src/ast/block.rs index d725774a8c..e57171db0e 100644 --- a/crates/nu-protocol/src/ast/block.rs +++ b/crates/nu-protocol/src/ast/block.rs @@ -1,5 +1,5 @@ -use super::Pipeline; -use crate::{Signature, Span, VarId}; +use super::{Expr, Expression, Pipeline}; +use crate::{ast::PipelineElement, engine::StateWorkingSet, Signature, Span, Type, VarId}; use serde::{Deserialize, Serialize}; use std::ops::{Index, IndexMut}; @@ -65,6 +65,56 @@ impl Block { recursive: None, } } + + pub fn input_type(&self, working_set: &StateWorkingSet) -> Type { + if let Some(first) = self.pipelines.first() { + if let Some(first) = first.elements.first() { + match first { + PipelineElement::Expression( + _, + Expression { + expr: Expr::Call(call), + .. + }, + ) => { + let decl = working_set.get_decl(call.decl_id); + + decl.signature().get_input_type() + } + PipelineElement::Expression( + _, + Expression { + expr: Expr::ExternalCall(..), + .. + }, + ) => Type::Any, + _ => Type::Nothing, + } + } else { + Type::Nothing + } + } else { + Type::Nothing + } + } + pub fn output_type(&self) -> Type { + if let Some(last) = self.pipelines.last() { + if let Some(last) = last.elements.last() { + match last { + PipelineElement::Expression(_, expr) => expr.ty.clone(), + PipelineElement::Redirection(_, _, _) => Type::Any, + PipelineElement::SeparateRedirection { .. } => Type::Any, + PipelineElement::SameTargetRedirection { .. } => Type::Any, + PipelineElement::And(_, expr) => expr.ty.clone(), + PipelineElement::Or(_, expr) => expr.ty.clone(), + } + } else { + Type::Nothing + } + } else { + Type::Nothing + } + } } impl From for Block diff --git a/crates/nu-protocol/src/engine/engine_state.rs b/crates/nu-protocol/src/engine/engine_state.rs index 5d8ef30288..4dc5e6c905 100644 --- a/crates/nu-protocol/src/engine/engine_state.rs +++ b/crates/nu-protocol/src/engine/engine_state.rs @@ -981,7 +981,7 @@ impl TypeScope { pub fn get_previous(&self) -> &Type { match self.outputs.last().and_then(|v| v.last()) { Some(input) => input, - None => &Type::Any, + None => &Type::Nothing, } } @@ -1193,7 +1193,7 @@ impl<'a> StateWorkingSet<'a> { pub fn add_decl(&mut self, decl: Box) -> DeclId { let name = decl.name().as_bytes().to_vec(); - let input_type = decl.signature().input_type; + let input_type = decl.signature().get_input_type(); self.delta.decls.push(decl); let decl_id = self.num_decls() - 1; diff --git a/crates/nu-protocol/src/engine/overlay.rs b/crates/nu-protocol/src/engine/overlay.rs index 640763bd37..0039cb291e 100644 --- a/crates/nu-protocol/src/engine/overlay.rs +++ b/crates/nu-protocol/src/engine/overlay.rs @@ -214,7 +214,23 @@ impl OverlayFrame { if let Some(decl) = self.decls.get(&(name, input) as &dyn DeclKey) { Some(*decl) } else { - self.decls.get(&(name, &Type::Any) as &dyn DeclKey).cloned() + // then fallback to not using the input type + for decl_key in self.decls.keys() { + if decl_key.0 == name { + // FIXME: this fallback may give bad type information + // in the case where no matching type is found. But, at + // least we treat it as a found internal command rather + // than an external command, which would cause further issues + return Some( + *self + .decls + .get(decl_key) + .expect("internal error: found decl not actually found"), + ); + } + } + + None } } } diff --git a/crates/nu-protocol/src/plugin_signature.rs b/crates/nu-protocol/src/plugin_signature.rs index 0185adefef..5c9dd06996 100644 --- a/crates/nu-protocol/src/plugin_signature.rs +++ b/crates/nu-protocol/src/plugin_signature.rs @@ -138,14 +138,8 @@ impl PluginSignature { } /// Changes the input type of the command signature - pub fn input_type(mut self, input_type: Type) -> PluginSignature { - self.sig = self.sig.input_type(input_type); - self - } - - /// Changes the output type of the command signature - pub fn output_type(mut self, output_type: Type) -> PluginSignature { - self.sig = self.sig.output_type(output_type); + pub fn input_output_type(mut self, input_type: Type, output_type: Type) -> PluginSignature { + self.sig.input_output_types.push((input_type, output_type)); self } diff --git a/crates/nu-protocol/src/signature.rs b/crates/nu-protocol/src/signature.rs index 071914d6ab..99026397d9 100644 --- a/crates/nu-protocol/src/signature.rs +++ b/crates/nu-protocol/src/signature.rs @@ -114,8 +114,6 @@ pub struct Signature { pub rest_positional: Option, pub vectorizes_over_list: bool, pub named: Vec, - pub input_type: Type, - pub output_type: Type, pub input_output_types: Vec<(Type, Type)>, pub allow_variants_without_examples: bool, pub is_filter: bool, @@ -215,8 +213,6 @@ impl Signature { optional_positional: vec![], rest_positional: None, vectorizes_over_list: false, - input_type: Type::Any, - output_type: Type::Any, input_output_types: vec![], allow_variants_without_examples: false, named: vec![], @@ -227,6 +223,46 @@ impl Signature { } } + // Gets the input type from the signature + pub fn get_input_type(&self) -> Type { + match self.input_output_types.len() { + 0 => Type::Any, + 1 => self.input_output_types[0].0.clone(), + _ => { + let first = &self.input_output_types[0].0; + if self + .input_output_types + .iter() + .all(|(input, _)| input == first) + { + first.clone() + } else { + Type::Any + } + } + } + } + + // Gets the output type from the signature + pub fn get_output_type(&self) -> Type { + match self.input_output_types.len() { + 0 => Type::Any, + 1 => self.input_output_types[0].1.clone(), + _ => { + let first = &self.input_output_types[0].1; + if self + .input_output_types + .iter() + .all(|(_, output)| output == first) + { + first.clone() + } else { + Type::Any + } + } + } + } + // Add a default help option to a signature pub fn add_help(mut self) -> Signature { // default help flag @@ -423,14 +459,8 @@ impl Signature { } /// Changes the input type of the command signature - pub fn input_type(mut self, input_type: Type) -> Signature { - self.input_type = input_type; - self - } - - /// Changes the output type of the command signature - pub fn output_type(mut self, output_type: Type) -> Signature { - self.output_type = output_type; + pub fn input_output_type(mut self, input_type: Type, output_type: Type) -> Signature { + self.input_output_types.push((input_type, output_type)); self } diff --git a/crates/nu-std/std/xml.nu b/crates/nu-std/std/xml.nu index 83ad08e2dd..b52dbe329b 100644 --- a/crates/nu-std/std/xml.nu +++ b/crates/nu-std/std/xml.nu @@ -19,7 +19,7 @@ export def xaccess [ # In xpath first element in path is applied to root element # this way it is possible to apply first step to root element # of nu xml without unrolling one step of loop - mut values = () + mut values: any = () $values = {content: [ { content: $input } ] } for $step in ($path) { match ($step | describe) { @@ -66,7 +66,7 @@ def xupdate-string-step [ step: string rest: list updater: closure ] { let new_values = ($to_update.item | xupdate-internal $rest $updater) - mut reenumerated_new_values = ($to_update.index | zip $new_values | each {|x| {index: $x.0 item: $x.1}}) + mut reenumerated_new_values: any = ($to_update.index | zip $new_values | each {|x| {index: $x.0 item: $x.1}}) mut new_content = [] for it in ($input.content | enumerate) { diff --git a/src/tests/test_parser.rs b/src/tests/test_parser.rs index 3382aa9c7a..2d97406891 100644 --- a/src/tests/test_parser.rs +++ b/src/tests/test_parser.rs @@ -576,3 +576,8 @@ fn filesize_with_underscores_3() -> TestResult { fn filesize_is_not_hex() -> TestResult { run_test("0x42b", "1067") } + +#[test] +fn let_variable_type_mismatch() -> TestResult { + fail_test(r#"let x: int = "foo""#, "expected int, found string") +}