Skip to content

Commit 6e9b4d9

Browse files
committed
raise typeerror if input is not list of str
1 parent 442e169 commit 6e9b4d9

14 files changed

Lines changed: 36 additions & 0 deletions

File tree

build/templates/_converters.py.mako

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ def convert_list_to_comma_separated_string(list_of_strings):
347347
Returns:
348348
str: Comma-separated string.
349349
'''
350+
if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings):
351+
raise TypeError('Input must be a list of str')
350352
return ','.join(list_of_strings)
351353

352354

generated/nidcpower/nidcpower/_converters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ def convert_list_to_comma_separated_string(list_of_strings):
338338
Returns:
339339
str: Comma-separated string.
340340
'''
341+
if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings):
342+
raise TypeError('Input must be a list of str')
341343
return ','.join(list_of_strings)
342344

343345

generated/nidigital/nidigital/_converters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ def convert_list_to_comma_separated_string(list_of_strings):
337337
Returns:
338338
str: Comma-separated string.
339339
'''
340+
if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings):
341+
raise TypeError('Input must be a list of str')
340342
return ','.join(list_of_strings)
341343

342344

generated/nidmm/nidmm/_converters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ def convert_list_to_comma_separated_string(list_of_strings):
337337
Returns:
338338
str: Comma-separated string.
339339
'''
340+
if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings):
341+
raise TypeError('Input must be a list of str')
340342
return ','.join(list_of_strings)
341343

342344

generated/nifake/nifake/_converters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ def convert_list_to_comma_separated_string(list_of_strings):
338338
Returns:
339339
str: Comma-separated string.
340340
'''
341+
if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings):
342+
raise TypeError('Input must be a list of str')
341343
return ','.join(list_of_strings)
342344

343345

generated/nifake/nifake/unit_tests/test_converters.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,3 +413,9 @@ def test_convert_comma_separated_string_to_list():
413413
def test_convert_list_to_comma_separated_string():
414414
out_string = _converters.convert_list_to_comma_separated_string(['PinA', 'PinB', 'PinC'])
415415
assert out_string == 'PinA,PinB,PinC'
416+
417+
418+
def test_convert_list_to_comma_separated_string_invalid_input():
419+
with pytest.raises(TypeError) as error_info:
420+
_converters.convert_list_to_comma_separated_string('PinA,PinB,PinC')
421+
assert str(error_info.value) == 'Input must be a list of str'

generated/nifgen/nifgen/_converters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ def convert_list_to_comma_separated_string(list_of_strings):
337337
Returns:
338338
str: Comma-separated string.
339339
'''
340+
if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings):
341+
raise TypeError('Input must be a list of str')
340342
return ','.join(list_of_strings)
341343

342344

generated/nimodinst/nimodinst/_converters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ def convert_list_to_comma_separated_string(list_of_strings):
337337
Returns:
338338
str: Comma-separated string.
339339
'''
340+
if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings):
341+
raise TypeError('Input must be a list of str')
340342
return ','.join(list_of_strings)
341343

342344

generated/nirfsg/nirfsg/_converters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ def convert_list_to_comma_separated_string(list_of_strings):
337337
Returns:
338338
str: Comma-separated string.
339339
'''
340+
if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings):
341+
raise TypeError('Input must be a list of str')
340342
return ','.join(list_of_strings)
341343

342344

generated/niscope/niscope/_converters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ def convert_list_to_comma_separated_string(list_of_strings):
337337
Returns:
338338
str: Comma-separated string.
339339
'''
340+
if not isinstance(list_of_strings, list) or not all(isinstance(item, str) for item in list_of_strings):
341+
raise TypeError('Input must be a list of str')
340342
return ','.join(list_of_strings)
341343

342344

0 commit comments

Comments
 (0)