Remove ListStream type (#14425)

# Description
List values and list streams have the same type (`list<>`). Rather,
streaming is a separate property of the pipeline/command output. This PR
removes the unnecessary `ListStream` type.

# User-Facing Changes
Should be none, except `random dice` now has a more specific output
type.
This commit is contained in:
Ian Manske 2024-11-26 17:35:55 -08:00 committed by GitHub
parent 186c08467f
commit 4edce44689
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 5 additions and 13 deletions

View File

@ -359,7 +359,6 @@ fn nu_value_to_sqlite_type(val: &Value) -> Result<&'static str, ShellError> {
| Type::Custom(_) | Type::Custom(_)
| Type::Error | Type::Error
| Type::List(_) | Type::List(_)
| Type::ListStream
| Type::Range | Type::Range
| Type::Record(_) | Type::Record(_)
| Type::Signature | Type::Signature

View File

@ -12,7 +12,7 @@ impl Command for SubCommand {
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
Signature::build("random dice") Signature::build("random dice")
.input_output_types(vec![(Type::Nothing, Type::ListStream)]) .input_output_types(vec![(Type::Nothing, Type::list(Type::Int))])
.allow_variants_without_examples(true) .allow_variants_without_examples(true)
.named( .named(
"dice", "dice",

View File

@ -15,7 +15,6 @@ impl Command for NuCheck {
Signature::build("nu-check") Signature::build("nu-check")
.input_output_types(vec![ .input_output_types(vec![
(Type::String, Type::Bool), (Type::String, Type::Bool),
(Type::ListStream, Type::Bool),
(Type::List(Box::new(Type::Any)), Type::Bool), (Type::List(Box::new(Type::Any)), Type::Bool),
]) ])
// type is string to avoid automatically canonicalizing the path // type is string to avoid automatically canonicalizing the path

View File

@ -29,8 +29,6 @@ pub fn type_compatible(lhs: &Type, rhs: &Type) -> bool {
match (lhs, rhs) { match (lhs, rhs) {
(Type::List(c), Type::List(d)) => type_compatible(c, d), (Type::List(c), Type::List(d)) => type_compatible(c, d),
(Type::ListStream, Type::List(_)) => true,
(Type::List(_), Type::ListStream) => true,
(Type::List(c), Type::Table(table_fields)) => { (Type::List(c), Type::Table(table_fields)) => {
if matches!(**c, Type::Any) { if matches!(**c, Type::Any) {
return true; return true;

View File

@ -109,7 +109,7 @@ impl PipelineData {
/// than would be returned by [`Value::get_type()`] on the result of /// than would be returned by [`Value::get_type()`] on the result of
/// [`.into_value()`](Self::into_value). /// [`.into_value()`](Self::into_value).
/// ///
/// Specifically, a `ListStream` results in [`list stream`](Type::ListStream) rather than /// Specifically, a `ListStream` results in `list<any>` rather than
/// the fully complete [`list`](Type::List) type (which would require knowing the contents), /// the fully complete [`list`](Type::List) type (which would require knowing the contents),
/// and a `ByteStream` with [unknown](crate::ByteStreamType::Unknown) type results in /// and a `ByteStream` with [unknown](crate::ByteStreamType::Unknown) type results in
/// [`any`](Type::Any) rather than [`string`](Type::String) or [`binary`](Type::Binary). /// [`any`](Type::Any) rather than [`string`](Type::String) or [`binary`](Type::Binary).
@ -117,7 +117,7 @@ impl PipelineData {
match self { match self {
PipelineData::Empty => Type::Nothing, PipelineData::Empty => Type::Nothing,
PipelineData::Value(value, _) => value.get_type(), PipelineData::Value(value, _) => value.get_type(),
PipelineData::ListStream(_, _) => Type::ListStream, PipelineData::ListStream(_, _) => Type::list(Type::Any),
PipelineData::ByteStream(stream, _) => stream.type_().into(), PipelineData::ByteStream(stream, _) => stream.type_().into(),
} }
} }

View File

@ -23,7 +23,6 @@ pub enum Type {
Float, Float,
Int, Int,
List(Box<Type>), List(Box<Type>),
ListStream,
#[default] #[default]
Nothing, Nothing,
Number, Number,
@ -121,7 +120,6 @@ impl Type {
Type::Nothing => SyntaxShape::Nothing, Type::Nothing => SyntaxShape::Nothing,
Type::Record(entries) => SyntaxShape::Record(mk_shape(entries)), Type::Record(entries) => SyntaxShape::Record(mk_shape(entries)),
Type::Table(columns) => SyntaxShape::Table(mk_shape(columns)), Type::Table(columns) => SyntaxShape::Table(mk_shape(columns)),
Type::ListStream => SyntaxShape::List(Box::new(SyntaxShape::Any)),
Type::Any => SyntaxShape::Any, Type::Any => SyntaxShape::Any,
Type::Error => SyntaxShape::Any, Type::Error => SyntaxShape::Any,
Type::Binary => SyntaxShape::Binary, Type::Binary => SyntaxShape::Binary,
@ -151,7 +149,6 @@ impl Type {
Type::Nothing => String::from("nothing"), Type::Nothing => String::from("nothing"),
Type::Number => String::from("number"), Type::Number => String::from("number"),
Type::String => String::from("string"), Type::String => String::from("string"),
Type::ListStream => String::from("list-stream"),
Type::Any => String::from("any"), Type::Any => String::from("any"),
Type::Error => String::from("error"), Type::Error => String::from("error"),
Type::Binary => String::from("binary"), Type::Binary => String::from("binary"),
@ -209,7 +206,6 @@ impl Display for Type {
Type::Nothing => write!(f, "nothing"), Type::Nothing => write!(f, "nothing"),
Type::Number => write!(f, "number"), Type::Number => write!(f, "number"),
Type::String => write!(f, "string"), Type::String => write!(f, "string"),
Type::ListStream => write!(f, "list-stream"),
Type::Any => write!(f, "any"), Type::Any => write!(f, "any"),
Type::Error => write!(f, "error"), Type::Error => write!(f, "error"),
Type::Binary => write!(f, "binary"), Type::Binary => write!(f, "binary"),

View File

@ -23,7 +23,7 @@ impl PluginCommand for ForEach {
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
Signature::build(self.name()) Signature::build(self.name())
.input_output_type(Type::ListStream, Type::Nothing) .input_output_type(Type::list(Type::Any), Type::Nothing)
.required( .required(
"closure", "closure",
SyntaxShape::Closure(Some(vec![SyntaxShape::Any])), SyntaxShape::Closure(Some(vec![SyntaxShape::Any])),

View File

@ -26,7 +26,7 @@ impl PluginCommand for Generate {
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
Signature::build(self.name()) Signature::build(self.name())
.input_output_type(Type::Nothing, Type::ListStream) .input_output_type(Type::Nothing, Type::list(Type::Any))
.required( .required(
"initial", "initial",
SyntaxShape::Any, SyntaxShape::Any,