/Users/nmidalgodias/Library/Caches/pypoetry/virtualenvs/sandbox-WXRoqCNu-py3.12/bin/python /Users/nmidalgodias/git/sandbox/src/make_targets/experimental/tinkoff_repro.py
Traceback (most recent call last):
File "/Users/nmidalgodias/git/sandbox/src/make_targets/experimental/tinkoff_repro.py", line 27, in <module>
main()
File "/Users/nmidalgodias/git/sandbox/src/make_targets/experimental/tinkoff_repro.py", line 20, in main
order_id = client.orders.replace_order(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/nmidalgodias/Library/Caches/pypoetry/virtualenvs/sandbox-WXRoqCNu-py3.12/lib/python3.12/site-packages/tinkoff/invest/_errors.py", line 23, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/nmidalgodias/Library/Caches/pypoetry/virtualenvs/sandbox-WXRoqCNu-py3.12/lib/python3.12/site-packages/tinkoff/invest/services.py", line 1401, in replace_order
request=_grpc_helpers.dataclass_to_protobuff(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/nmidalgodias/Library/Caches/pypoetry/virtualenvs/sandbox-WXRoqCNu-py3.12/lib/python3.12/site-packages/tinkoff/invest/_grpc_helpers.py", line 404, in dataclass_to_protobuff
_update_field(first_arg, protobuff_obj, field_name, field_value)
File "/Users/nmidalgodias/Library/Caches/pypoetry/virtualenvs/sandbox-WXRoqCNu-py3.12/lib/python3.12/site-packages/tinkoff/invest/_grpc_helpers.py", line 430, in _update_field
setattr(protobuff_obj, field_name, field_value.value)
^^^^^^^^^^^^^^^^^
AttributeError: 'Field' object has no attribute 'value'
Process finished with exit code 1
Что случилось?
Пропущен декоратор
@dataclass
в классе ReplaceOrderRequesthttps://github.com/RussianInvestments/invest-python/blob/5836ddce21d8dbbe48a5325f45f0167f4d62db03/tinkoff/invest/schemas.py#L2213
Из за этого, вызов
client.orders.replace_order(request)
падает с исключениемЕсли добавить
@dataclass
в исходниках вschemas.py
, исключения нет, вызов API срабатывает штатно.Воспроизведение
Workaround
Заполнить необязательное поле
Tinkoff Invest Version
0.2.0-beta98
Python Version
3.12
OS
MacOS
Логи