diff --git a/build/templates/_converters.py.mako b/build/templates/_converters.py.mako index ef4e5c323..2ee4ba663 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 2f0dd3c5c..3c80fcb7c 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 61d2f3d9a..e645ad43d 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 c08dde095..7dcf49ee8 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 9150b5d55..9de6fa694 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 b82ee00e6..daa0d2196 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 5747b17ad..1d18df460 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 de922a9df..666c3c925 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 a8a7b828a..e5c50c04d 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 7cc8581c9..78518a913 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 255dc8b9b..98fd3af42 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 70a66865f..e72487bda 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 d73f8b35f..8c1395257 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 b82ee00e6..daa0d2196 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'