@datareset
развиваюсь.

ValueError: dictionary update sequence element #0 has length 1; 2 is required. Что делать?

class DrawData(StatesGroup):
    enterData = State()
@dp.message_handler(commands = ['start'])
async def start(message: types.Message):
    await message.answer('Меню: ', reply_markup=menuKeyboard)
@dp.callback_query_handler(text='draw')
async def draw(call: types.CallbackQuery):
    await call.answer()
    await call.message.answer('Введи значения через перенос')
    await DrawData.enterData.set()
@dp.message_handler(state=DrawData.enterData)
async def configToDraw(message: types.Message, state: FSMContext):
    await state.update_data(data=message.text)
    print('state active')
    drawData = await state.get_data()
    print(drawData['data'])
    await state.finish()

Как исправить? Полный трейсбек:
Traceback (most recent call last):
  File "/home//.local/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 415, in _process_polling_updates
    for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
  File "/home//.local/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 235, in process_updates
    return await asyncio.gather(*tasks)
  File "/home//.local/lib/python3.9/site-packages/aiogram/dispatcher/handler.py", line 116, in notify
    response = await handler_obj.handler(*args, **partial_data)
  File "/home//.local/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 256, in process_update
    return await self.message_handlers.notify(update.message)
  File "/home//.local/lib/python3.9/site-packages/aiogram/dispatcher/handler.py", line 116, in notify
    response = await handler_obj.handler(*args, **partial_data)
  File "/home//bot.py", line 41, in configToDraw
    await state.update_data(data=message.text)
  File "/home//.local/lib/python3.9/site-packages/aiogram/dispatcher/storage.py", line 307, in update_data
    await self.storage.update_data(chat=self.chat, user=self.user, data=data, **kwargs)
  File "/home//.local/lib/python3.9/site-packages/aiogram/contrib/fsm_storage/memory.py", line 54, in update_data
    self.data[chat][user]['data'].update(data, **kwargs)
ValueError: dictionary update sequence element #0 has length 1; 2 is required
  • Вопрос задан
  • 3108 просмотров
Пригласить эксперта
Ответы на вопрос 1
@Aghanimoff
Подозреваю, что update_data хочет принимать либо kwargs (пары ключ=значение), либо data в формате словаря.
Попробуй что-то из этого:

  1. text=message.text
  2. data={"text": message.text}
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы