Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions flytekit/common/types/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,15 @@ def from_string(cls, string_value):
:param Text string_value:
:rtype: ListImpl<T>
"""

try:
items = _json.loads(string_value)
except ValueError:
raise _user_exceptions.FlyteTypeException(
_six.text_type, TypedListImpl, additional_msg='String not parseable to json {}'.format(string_value))
_six.text_type, cls, additional_msg='String not parseable to json {}'.format(string_value))

if type(items) != list:
raise _user_exceptions.FlyteTypeException(
_six.text_type, TypedListImpl, additional_msg='String is not a list {}'.format(string_value))
_six.text_type, cls, additional_msg='String is not a list {}'.format(string_value))

# Instead of recursively calling from_string(), we're changing to from_python_std() instead because json
# loading naturally interprets all layers, not just the outer layer.
Expand Down Expand Up @@ -130,7 +129,7 @@ def to_python_std(self):
"""
:rtype: list[T]
"""
return [self._sub_type.from_flyte_idl(l.to_flyte_idl()).to_python_std() for l in self.collection.literals]
return [type(self).sub_type.from_flyte_idl(l.to_flyte_idl()).to_python_std() for l in self.collection.literals]

def short_string(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ max-complexity=16
[tool:pytest]
norecursedirs = common workflows spark
log_cli = true
log_cli_level = 0
log_cli_level = 100

[pep8]
max-line-length = 120
Expand Down
6 changes: 6 additions & 0 deletions tests/flytekit/unit/common_tests/types/test_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def test_list():
with pytest.raises(_user_exceptions.FlyteTypeException):
list_type.from_string('[1, 2, 3, []]')

with pytest.raises(_user_exceptions.FlyteTypeException):
list_type.from_string('\'["not list json"]\'')

with pytest.raises(_user_exceptions.FlyteTypeException):
list_type.from_string('["unclosed","list"')


def test_string_list():
list_type = containers.List(primitives.String)
Expand Down