How to convert protobuf ListValue into python List?

665 Views Asked by At

I have a protobuf ListValue which I would like to convert into a Python List. However, I believe I have a conceptual misunderstanding as the following attempts have failed

my_list_value: ListValue = ...
my_list = list(my_list_value)

and mypy complains:

error: No overload variant of "list" matches argument type "ListValue"

Similarly, I tried:

prob_output_list: List[float] = []
for elt in my_list_value:
  prob_output_list.append(elt)

yet also receive

error: "ListValue" has no attribute "__iter__" (not iterable)
Found 1 error in 1 file (checked 1 source file)

How can we explicitly force a cast without triggering mypy? Would it be just via #pragma ignore

0

There are 0 best solutions below