From 6e9b4d98ec6017c030ddb831dd873e69e294031d Mon Sep 17 00:00:00 2001 From: vnktshr21 <12389486+vnktshr21@users.noreply.github.com> Date: Wed, 7 Jan 2026 15:02:00 +0530 Subject: [PATCH 1/2] raise typeerror if input is not list of str --- build/templates/_converters.py.mako | 2 ++ generated/nidcpower/nidcpower/_converters.py | 2 ++ generated/nidigital/nidigital/_converters.py | 2 ++ generated/nidmm/nidmm/_converters.py | 2 ++ generated/nifake/nifake/_converters.py | 2 ++ generated/nifake/nifake/unit_tests/test_converters.py | 6 ++++++ generated/nifgen/nifgen/_converters.py | 2 ++ generated/nimodinst/nimodinst/_converters.py | 2 ++ generated/nirfsg/nirfsg/_converters.py | 2 ++ generated/niscope/niscope/_converters.py | 2 ++ generated/nise/nise/_converters.py | 2 ++ generated/niswitch/niswitch/_converters.py | 2 ++ generated/nitclk/nitclk/_converters.py | 2 ++ src/nifake/unit_tests/test_converters.py | 6 ++++++ 14 files changed, 36 insertions(+) diff --git a/build/templates/_converters.py.mako b/build/templates/_converters.py.mako index ef4e5c323..6597d5f59 100644 --- a/build/templates/_converters.py.mako +++ b/build/templates/_converters.py.mako @@ -347,6 +347,8 @@ def convert_list_to_comma_separated_string(list_of_strings): Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list of str') return ','.join(list_of_strings) diff --git a/generated/nidcpower/nidcpower/_converters.py b/generated/nidcpower/nidcpower/_converters.py index 2f0dd3c5c..244696392 100644 --- a/generated/nidcpower/nidcpower/_converters.py +++ b/generated/nidcpower/nidcpower/_converters.py @@ -338,6 +338,8 @@ def convert_list_to_comma_separated_string(list_of_strings): Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list of str') return ','.join(list_of_strings) diff --git a/generated/nidigital/nidigital/_converters.py b/generated/nidigital/nidigital/_converters.py index 61d2f3d9a..d572311b7 100644 --- a/generated/nidigital/nidigital/_converters.py +++ b/generated/nidigital/nidigital/_converters.py @@ -337,6 +337,8 @@ def convert_list_to_comma_separated_string(list_of_strings): Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list of str') return ','.join(list_of_strings) diff --git a/generated/nidmm/nidmm/_converters.py b/generated/nidmm/nidmm/_converters.py index c08dde095..f6c6cac89 100644 --- a/generated/nidmm/nidmm/_converters.py +++ b/generated/nidmm/nidmm/_converters.py @@ -337,6 +337,8 @@ def convert_list_to_comma_separated_string(list_of_strings): Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list of str') return ','.join(list_of_strings) diff --git a/generated/nifake/nifake/_converters.py b/generated/nifake/nifake/_converters.py index 9150b5d55..e867c9458 100644 --- a/generated/nifake/nifake/_converters.py +++ b/generated/nifake/nifake/_converters.py @@ -338,6 +338,8 @@ def convert_list_to_comma_separated_string(list_of_strings): Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list 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..9e1a20e72 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 of str' diff --git a/generated/nifgen/nifgen/_converters.py b/generated/nifgen/nifgen/_converters.py index 5747b17ad..073c7fea1 100644 --- a/generated/nifgen/nifgen/_converters.py +++ b/generated/nifgen/nifgen/_converters.py @@ -337,6 +337,8 @@ def convert_list_to_comma_separated_string(list_of_strings): Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list of str') return ','.join(list_of_strings) diff --git a/generated/nimodinst/nimodinst/_converters.py b/generated/nimodinst/nimodinst/_converters.py index de922a9df..cde1dcada 100644 --- a/generated/nimodinst/nimodinst/_converters.py +++ b/generated/nimodinst/nimodinst/_converters.py @@ -337,6 +337,8 @@ def convert_list_to_comma_separated_string(list_of_strings): Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list of str') return ','.join(list_of_strings) diff --git a/generated/nirfsg/nirfsg/_converters.py b/generated/nirfsg/nirfsg/_converters.py index a8a7b828a..2e4695fee 100644 --- a/generated/nirfsg/nirfsg/_converters.py +++ b/generated/nirfsg/nirfsg/_converters.py @@ -337,6 +337,8 @@ def convert_list_to_comma_separated_string(list_of_strings): Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list of str') return ','.join(list_of_strings) diff --git a/generated/niscope/niscope/_converters.py b/generated/niscope/niscope/_converters.py index 7cc8581c9..2b2db7692 100644 --- a/generated/niscope/niscope/_converters.py +++ b/generated/niscope/niscope/_converters.py @@ -337,6 +337,8 @@ def convert_list_to_comma_separated_string(list_of_strings): Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list of str') return ','.join(list_of_strings) diff --git a/generated/nise/nise/_converters.py b/generated/nise/nise/_converters.py index 255dc8b9b..221045462 100644 --- a/generated/nise/nise/_converters.py +++ b/generated/nise/nise/_converters.py @@ -337,6 +337,8 @@ def convert_list_to_comma_separated_string(list_of_strings): Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list of str') return ','.join(list_of_strings) diff --git a/generated/niswitch/niswitch/_converters.py b/generated/niswitch/niswitch/_converters.py index 70a66865f..a2e66fcee 100644 --- a/generated/niswitch/niswitch/_converters.py +++ b/generated/niswitch/niswitch/_converters.py @@ -337,6 +337,8 @@ def convert_list_to_comma_separated_string(list_of_strings): Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list of str') return ','.join(list_of_strings) diff --git a/generated/nitclk/nitclk/_converters.py b/generated/nitclk/nitclk/_converters.py index d73f8b35f..ba0b55e9b 100644 --- a/generated/nitclk/nitclk/_converters.py +++ b/generated/nitclk/nitclk/_converters.py @@ -337,6 +337,8 @@ def convert_list_to_comma_separated_string(list_of_strings): Returns: str: Comma-separated string. ''' + if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings): + raise TypeError('Input must be a list 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..9e1a20e72 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 of str' From 6cf9c8c87a733d11a377f09ae30d9bf178e38dc4 Mon Sep 17 00:00:00 2001 From: vnktshr21 <12389486+vnktshr21@users.noreply.github.com> Date: Thu, 8 Jan 2026 13:32:46 +0530 Subject: [PATCH 2/2] allow tuple iterable along with list --- build/templates/_converters.py.mako | 8 ++++---- generated/nidcpower/nidcpower/_converters.py | 8 ++++---- generated/nidigital/nidigital/_converters.py | 8 ++++---- generated/nidmm/nidmm/_converters.py | 8 ++++---- generated/nifake/nifake/_converters.py | 8 ++++---- generated/nifake/nifake/unit_tests/test_converters.py | 2 +- generated/nifgen/nifgen/_converters.py | 8 ++++---- generated/nimodinst/nimodinst/_converters.py | 8 ++++---- generated/nirfsg/nirfsg/_converters.py | 8 ++++---- generated/niscope/niscope/_converters.py | 8 ++++---- generated/nise/nise/_converters.py | 8 ++++---- generated/niswitch/niswitch/_converters.py | 8 ++++---- generated/nitclk/nitclk/_converters.py | 8 ++++---- src/nifake/unit_tests/test_converters.py | 2 +- 14 files changed, 50 insertions(+), 50 deletions(-) diff --git a/build/templates/_converters.py.mako b/build/templates/_converters.py.mako index 6597d5f59..2ee4ba663 100644 --- a/build/templates/_converters.py.mako +++ b/build/templates/_converters.py.mako @@ -339,16 +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) or not all(isinstance(item, str) for item in list_of_strings): - raise TypeError('Input must be a list of str') + 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 244696392..3c80fcb7c 100644 --- a/generated/nidcpower/nidcpower/_converters.py +++ b/generated/nidcpower/nidcpower/_converters.py @@ -330,16 +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) or not all(isinstance(item, str) for item in list_of_strings): - raise TypeError('Input must be a list of str') + 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 d572311b7..e645ad43d 100644 --- a/generated/nidigital/nidigital/_converters.py +++ b/generated/nidigital/nidigital/_converters.py @@ -329,16 +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) or not all(isinstance(item, str) for item in list_of_strings): - raise TypeError('Input must be a list of str') + 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 f6c6cac89..7dcf49ee8 100644 --- a/generated/nidmm/nidmm/_converters.py +++ b/generated/nidmm/nidmm/_converters.py @@ -329,16 +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) or not all(isinstance(item, str) for item in list_of_strings): - raise TypeError('Input must be a list of str') + 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 e867c9458..9de6fa694 100644 --- a/generated/nifake/nifake/_converters.py +++ b/generated/nifake/nifake/_converters.py @@ -330,16 +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) or not all(isinstance(item, str) for item in list_of_strings): - raise TypeError('Input must be a list of str') + 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 9e1a20e72..daa0d2196 100644 --- a/generated/nifake/nifake/unit_tests/test_converters.py +++ b/generated/nifake/nifake/unit_tests/test_converters.py @@ -418,4 +418,4 @@ def test_convert_list_to_comma_separated_string(): 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 of str' + 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 073c7fea1..1d18df460 100644 --- a/generated/nifgen/nifgen/_converters.py +++ b/generated/nifgen/nifgen/_converters.py @@ -329,16 +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) or not all(isinstance(item, str) for item in list_of_strings): - raise TypeError('Input must be a list of str') + 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 cde1dcada..666c3c925 100644 --- a/generated/nimodinst/nimodinst/_converters.py +++ b/generated/nimodinst/nimodinst/_converters.py @@ -329,16 +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) or not all(isinstance(item, str) for item in list_of_strings): - raise TypeError('Input must be a list of str') + 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 2e4695fee..e5c50c04d 100644 --- a/generated/nirfsg/nirfsg/_converters.py +++ b/generated/nirfsg/nirfsg/_converters.py @@ -329,16 +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) or not all(isinstance(item, str) for item in list_of_strings): - raise TypeError('Input must be a list of str') + 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 2b2db7692..78518a913 100644 --- a/generated/niscope/niscope/_converters.py +++ b/generated/niscope/niscope/_converters.py @@ -329,16 +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) or not all(isinstance(item, str) for item in list_of_strings): - raise TypeError('Input must be a list of str') + 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 221045462..98fd3af42 100644 --- a/generated/nise/nise/_converters.py +++ b/generated/nise/nise/_converters.py @@ -329,16 +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) or not all(isinstance(item, str) for item in list_of_strings): - raise TypeError('Input must be a list of str') + 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 a2e66fcee..e72487bda 100644 --- a/generated/niswitch/niswitch/_converters.py +++ b/generated/niswitch/niswitch/_converters.py @@ -329,16 +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) or not all(isinstance(item, str) for item in list_of_strings): - raise TypeError('Input must be a list of str') + 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 ba0b55e9b..8c1395257 100644 --- a/generated/nitclk/nitclk/_converters.py +++ b/generated/nitclk/nitclk/_converters.py @@ -329,16 +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) or not all(isinstance(item, str) for item in list_of_strings): - raise TypeError('Input must be a list of str') + 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 9e1a20e72..daa0d2196 100644 --- a/src/nifake/unit_tests/test_converters.py +++ b/src/nifake/unit_tests/test_converters.py @@ -418,4 +418,4 @@ def test_convert_list_to_comma_separated_string(): 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 of str' + assert str(error_info.value) == 'Input must be a list or tuple of str'