Skip to content

Allow IfElseSubstitution to return lists. #464

@robin-zealrobotics

Description

@robin-zealrobotics

Description

Allowing something like this to work

Node(
    # other stuff
    # ...
    parameters=[
        {
            "some_array_type": IfElseSubstitution(
                condition=some_condition,
                if_value=[subs1],
                else_value=[subs1, subs2, subs3],
            )
        },
    ],
)

Motivation

The snippet below works, so it seems intuitive that wrapping that in an if-else substitution would work as well.

Node(
    # typical stuff
    # ...
    parameters=[
        {
            "some_array_type": [subs1, subs2, subs3],
        },
    ],
)

Design / Implementation Considerations

No response

Additional Information

I have no idea if this is feasible or not. The way iterables of substitutions are handled is typically concatenating them, but apparently not when using them for parameters, as that is able to correctly handle lists. I would assume that logic might be usable for IfElseSubstitions as well.
Looking through the allowed types, the parameters allow for

SomeParameterValue = Union[
    ParameterValueDescription,
    SomeSubstitutionsType,
    Sequence[SomeSubstitutionsType],
    _SingleValueType,
    _MultiValueType
]

While IfElseSubstition doesn't handle a sequence and only handles

SomeSubstitutionsType = Union[
    Text,
    Substitution,
    Iterable[Union[Text, Substitution]],
]

I would also expect similar limitations exist elsewhere and this is probably not exclusive to IfElseSubstitution.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions