I'm using pb_2 and want to consturct instances of a message but keep facing positional argument error. I can construct instances from all other messages but when it comes to the following example, I get stcuk.
I have the following three messages:
message Foo {
int32 num = 1;
repeated KeyValuePair features = 2;
}
message KeyValuePair {
string key = 1;
Value value = 2;
}
message Value {
oneof oneOfValue {
string strValue = 1;
int64 intValue = 2;
}
}
I want to construct an instance of Foo that looks like this:
foo {
num: 123
features: [KeyValuePair {key: 'key1', value: 'value1'},
KeyValuePair {key: 'key2', value: 'value2'}]
}
I tried the following and keep getting positional argument error ('no positional arguments allowed'):
my_foo = Foo(num=123,
features=[KeyValuePair(key='key1', value='value1'),
KeyValuePair(key='key2', value='value2')])
I am not using any positional arguments. Can anyone help?
Thanks!