diff --git a/build/templates/_converters.py.mako b/build/templates/_converters.py.mako index ef4e5c3239..2ee4ba6630 100644 --- a/build/templates/_converters.py.mako +++ b/build/templates/_converters.py.mako @@ -339,14 +339,16 @@ def convert_comma_separated_string_to_list(comma_separated_string): def convert_list_to_comma_separated_string(list_of_strings): - '''Convert a list of strings into a comma-separated string. + '''Convert a list or tuple of strings into a comma-separated string. Args: - list_of_strings (list[str]): List of strings. + list_of_strings (list or tuple of str): List or tuple of strings. Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, (list, tuple)) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list or tuple of str') return ','.join(list_of_strings) diff --git a/generated/nidcpower/nidcpower/_converters.py b/generated/nidcpower/nidcpower/_converters.py index 2f0dd3c5cb..3c80fcb7cc 100644 --- a/generated/nidcpower/nidcpower/_converters.py +++ b/generated/nidcpower/nidcpower/_converters.py @@ -330,14 +330,16 @@ def convert_comma_separated_string_to_list(comma_separated_string): def convert_list_to_comma_separated_string(list_of_strings): - '''Convert a list of strings into a comma-separated string. + '''Convert a list or tuple of strings into a comma-separated string. Args: - list_of_strings (list[str]): List of strings. + list_of_strings (list or tuple of str): List or tuple of strings. Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, (list, tuple)) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list or tuple of str') return ','.join(list_of_strings) diff --git a/generated/nidigital/nidigital/_converters.py b/generated/nidigital/nidigital/_converters.py index 61d2f3d9a2..e645ad43d4 100644 --- a/generated/nidigital/nidigital/_converters.py +++ b/generated/nidigital/nidigital/_converters.py @@ -329,14 +329,16 @@ def convert_comma_separated_string_to_list(comma_separated_string): def convert_list_to_comma_separated_string(list_of_strings): - '''Convert a list of strings into a comma-separated string. + '''Convert a list or tuple of strings into a comma-separated string. Args: - list_of_strings (list[str]): List of strings. + list_of_strings (list or tuple of str): List or tuple of strings. Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, (list, tuple)) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list or tuple of str') return ','.join(list_of_strings) diff --git a/generated/nidmm/nidmm/_converters.py b/generated/nidmm/nidmm/_converters.py index c08dde095e..7dcf49ee8f 100644 --- a/generated/nidmm/nidmm/_converters.py +++ b/generated/nidmm/nidmm/_converters.py @@ -329,14 +329,16 @@ def convert_comma_separated_string_to_list(comma_separated_string): def convert_list_to_comma_separated_string(list_of_strings): - '''Convert a list of strings into a comma-separated string. + '''Convert a list or tuple of strings into a comma-separated string. Args: - list_of_strings (list[str]): List of strings. + list_of_strings (list or tuple of str): List or tuple of strings. Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, (list, tuple)) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list or tuple of str') return ','.join(list_of_strings) diff --git a/generated/nifake/nifake/_converters.py b/generated/nifake/nifake/_converters.py index 9150b5d55c..9de6fa6942 100644 --- a/generated/nifake/nifake/_converters.py +++ b/generated/nifake/nifake/_converters.py @@ -330,14 +330,16 @@ def convert_comma_separated_string_to_list(comma_separated_string): def convert_list_to_comma_separated_string(list_of_strings): - '''Convert a list of strings into a comma-separated string. + '''Convert a list or tuple of strings into a comma-separated string. Args: - list_of_strings (list[str]): List of strings. + list_of_strings (list or tuple of str): List or tuple of strings. Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, (list, tuple)) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list or tuple of str') return ','.join(list_of_strings) diff --git a/generated/nifake/nifake/unit_tests/test_converters.py b/generated/nifake/nifake/unit_tests/test_converters.py index b82ee00e68..daa0d21963 100644 --- a/generated/nifake/nifake/unit_tests/test_converters.py +++ b/generated/nifake/nifake/unit_tests/test_converters.py @@ -413,3 +413,9 @@ def test_convert_comma_separated_string_to_list(): def test_convert_list_to_comma_separated_string(): out_string = _converters.convert_list_to_comma_separated_string(['PinA', 'PinB', 'PinC']) assert out_string == 'PinA,PinB,PinC' + + +def test_convert_list_to_comma_separated_string_invalid_input(): + with pytest.raises(TypeError) as error_info: + _converters.convert_list_to_comma_separated_string('PinA,PinB,PinC') + assert str(error_info.value) == 'Input must be a list or tuple of str' diff --git a/generated/nifgen/nifgen/_converters.py b/generated/nifgen/nifgen/_converters.py index 5747b17ad2..1d18df460c 100644 --- a/generated/nifgen/nifgen/_converters.py +++ b/generated/nifgen/nifgen/_converters.py @@ -329,14 +329,16 @@ def convert_comma_separated_string_to_list(comma_separated_string): def convert_list_to_comma_separated_string(list_of_strings): - '''Convert a list of strings into a comma-separated string. + '''Convert a list or tuple of strings into a comma-separated string. Args: - list_of_strings (list[str]): List of strings. + list_of_strings (list or tuple of str): List or tuple of strings. Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, (list, tuple)) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list or tuple of str') return ','.join(list_of_strings) diff --git a/generated/nimodinst/nimodinst/_converters.py b/generated/nimodinst/nimodinst/_converters.py index de922a9dfd..666c3c925e 100644 --- a/generated/nimodinst/nimodinst/_converters.py +++ b/generated/nimodinst/nimodinst/_converters.py @@ -329,14 +329,16 @@ def convert_comma_separated_string_to_list(comma_separated_string): def convert_list_to_comma_separated_string(list_of_strings): - '''Convert a list of strings into a comma-separated string. + '''Convert a list or tuple of strings into a comma-separated string. Args: - list_of_strings (list[str]): List of strings. + list_of_strings (list or tuple of str): List or tuple of strings. Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, (list, tuple)) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list or tuple of str') return ','.join(list_of_strings) diff --git a/generated/nirfsg/nirfsg/_converters.py b/generated/nirfsg/nirfsg/_converters.py index a8a7b828a7..e5c50c04d3 100644 --- a/generated/nirfsg/nirfsg/_converters.py +++ b/generated/nirfsg/nirfsg/_converters.py @@ -329,14 +329,16 @@ def convert_comma_separated_string_to_list(comma_separated_string): def convert_list_to_comma_separated_string(list_of_strings): - '''Convert a list of strings into a comma-separated string. + '''Convert a list or tuple of strings into a comma-separated string. Args: - list_of_strings (list[str]): List of strings. + list_of_strings (list or tuple of str): List or tuple of strings. Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, (list, tuple)) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list or tuple of str') return ','.join(list_of_strings) diff --git a/generated/niscope/niscope/_converters.py b/generated/niscope/niscope/_converters.py index 7cc8581c91..78518a9132 100644 --- a/generated/niscope/niscope/_converters.py +++ b/generated/niscope/niscope/_converters.py @@ -329,14 +329,16 @@ def convert_comma_separated_string_to_list(comma_separated_string): def convert_list_to_comma_separated_string(list_of_strings): - '''Convert a list of strings into a comma-separated string. + '''Convert a list or tuple of strings into a comma-separated string. Args: - list_of_strings (list[str]): List of strings. + list_of_strings (list or tuple of str): List or tuple of strings. Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, (list, tuple)) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list or tuple of str') return ','.join(list_of_strings) diff --git a/generated/nise/nise/_converters.py b/generated/nise/nise/_converters.py index 255dc8b9bf..98fd3af425 100644 --- a/generated/nise/nise/_converters.py +++ b/generated/nise/nise/_converters.py @@ -329,14 +329,16 @@ def convert_comma_separated_string_to_list(comma_separated_string): def convert_list_to_comma_separated_string(list_of_strings): - '''Convert a list of strings into a comma-separated string. + '''Convert a list or tuple of strings into a comma-separated string. Args: - list_of_strings (list[str]): List of strings. + list_of_strings (list or tuple of str): List or tuple of strings. Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, (list, tuple)) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list or tuple of str') return ','.join(list_of_strings) diff --git a/generated/niswitch/niswitch/_converters.py b/generated/niswitch/niswitch/_converters.py index 70a66865f4..e72487bda4 100644 --- a/generated/niswitch/niswitch/_converters.py +++ b/generated/niswitch/niswitch/_converters.py @@ -329,14 +329,16 @@ def convert_comma_separated_string_to_list(comma_separated_string): def convert_list_to_comma_separated_string(list_of_strings): - '''Convert a list of strings into a comma-separated string. + '''Convert a list or tuple of strings into a comma-separated string. Args: - list_of_strings (list[str]): List of strings. + list_of_strings (list or tuple of str): List or tuple of strings. Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, (list, tuple)) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list or tuple of str') return ','.join(list_of_strings) diff --git a/generated/nitclk/nitclk/_converters.py b/generated/nitclk/nitclk/_converters.py index d73f8b35f8..8c1395257e 100644 --- a/generated/nitclk/nitclk/_converters.py +++ b/generated/nitclk/nitclk/_converters.py @@ -329,14 +329,16 @@ def convert_comma_separated_string_to_list(comma_separated_string): def convert_list_to_comma_separated_string(list_of_strings): - '''Convert a list of strings into a comma-separated string. + '''Convert a list or tuple of strings into a comma-separated string. Args: - list_of_strings (list[str]): List of strings. + list_of_strings (list or tuple of str): List or tuple of strings. Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, (list, tuple)) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list or tuple of str') return ','.join(list_of_strings) diff --git a/src/nifake/unit_tests/test_converters.py b/src/nifake/unit_tests/test_converters.py index b82ee00e68..daa0d21963 100644 --- a/src/nifake/unit_tests/test_converters.py +++ b/src/nifake/unit_tests/test_converters.py @@ -413,3 +413,9 @@ def test_convert_comma_separated_string_to_list(): def test_convert_list_to_comma_separated_string(): out_string = _converters.convert_list_to_comma_separated_string(['PinA', 'PinB', 'PinC']) assert out_string == 'PinA,PinB,PinC' + + +def test_convert_list_to_comma_separated_string_invalid_input(): + with pytest.raises(TypeError) as error_info: + _converters.convert_list_to_comma_separated_string('PinA,PinB,PinC') + assert str(error_info.value) == 'Input must be a list or tuple of str'