From 65f23a6cb5b70e4a162af6a6da233dbb851d60c0 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Tue, 5 Mar 2019 16:21:18 -0800 Subject: [PATCH] SomeParameterValue multi value substitutions Signed-off-by: Shane Loretz --- launch_ros/launch_ros/parameters_type.py | 5 ++++- launch_ros/launch_ros/utilities/normalize_parameters.py | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/launch_ros/launch_ros/parameters_type.py b/launch_ros/launch_ros/parameters_type.py index 3cd4001b2..fb2dc495f 100644 --- a/launch_ros/launch_ros/parameters_type.py +++ b/launch_ros/launch_ros/parameters_type.py @@ -33,7 +33,10 @@ SomeParameterFile = Union[SomeSubstitutionsType, pathlib.Path] SomeParameterName = Sequence[Union[Substitution, str]] -SomeParameterValue = Union[SomeSubstitutionsType, _SingleValueType, _MultiValueType] +SomeParameterValue = Union[SomeSubstitutionsType, + Sequence[SomeSubstitutionsType], + _SingleValueType, + _MultiValueType] # TODO(sloretz) Recursive type when mypy supports them python/mypy#731 _SomeParametersDict = Mapping[SomeParameterName, Any] diff --git a/launch_ros/launch_ros/utilities/normalize_parameters.py b/launch_ros/launch_ros/utilities/normalize_parameters.py index 55c4077af..35040d835 100644 --- a/launch_ros/launch_ros/utilities/normalize_parameters.py +++ b/launch_ros/launch_ros/utilities/normalize_parameters.py @@ -68,11 +68,13 @@ def _normalize_parameter_array_value(value: SomeParameterValue) -> ParameterValu raise RuntimeError('Failed to handle type {}'.format(repr(subvalue))) if {int} == has_types: - # all integers - return tuple(int(e) for e in value) + # everything is an integer + make_mypy_happy_int = cast(List[int], value) + return tuple(int(e) for e in make_mypy_happy_int) elif has_types in ({float}, {int, float}): # all were floats or ints, so return floats - return tuple(float(e) for e in value) + make_mypy_happy_float = cast(List[Union[int, float]], value) + return tuple(float(e) for e in make_mypy_happy_float) elif Substitution in has_types and has_types.issubset({str, Substitution, tuple}): # make a list of substitutions forming a single string return tuple(normalize_to_list_of_substitutions(cast(SomeSubstitutionsType, value)))