Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReplyKeyboardMarkup: __init__() got an unexpected keyword argument 'conf' #343

Closed
nacknime-official opened this issue May 30, 2020 · 0 comments · Fixed by #344
Closed

ReplyKeyboardMarkup: __init__() got an unexpected keyword argument 'conf' #343

nacknime-official opened this issue May 30, 2020 · 0 comments · Fixed by #344
Labels
bug Something is wrong with the framework

Comments

@nacknime-official
Copy link

  • Operating System: Linux
  • Python Version: 3.8.2
  • aiogram version: 2.8
  • aiohttp version: 3.6.2
  • uvloop version (if installed): Not installed

Expected Behavior

I wanna put a reply keyboard object into the redis storage, but it's impossible. I saw to_python() method of the ReplyKeyboardMarkup object and decided that I'll use that method to serialize the object in the redis storage and I'll use to_object(data) method to get the keyboard from the redis storage and back it to object.

Current Behavior

If I use the KeyboardButton object for ReplyKeyboarkMarkup.add() method, it'll return an error when I do to_object()
If I don't use that and just put a string into ReplyKeyboarkMarkup.add() method, it'll works fine without any error.

Failure Information (for bugs)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/site-packages/aiogram/types/base.py", line 145, in to_object
    return cls(**data)
  File "/usr/lib/python3.8/site-packages/aiogram/types/reply_keyboard.py", line 35, in __init__
    super(ReplyKeyboardMarkup, self).__init__(keyboard=keyboard, resize_keyboard=resize_keyboard,
  File "/usr/lib/python3.8/site-packages/aiogram/types/base.py", line 91, in __init__
    self.props[key].set_value(self, value, parent=self)
  File "/usr/lib/python3.8/site-packages/aiogram/types/fields.py", line 56, in set_value
    value = self.deserialize(value, parent)
  File "/usr/lib/python3.8/site-packages/aiogram/types/fields.py", line 161, in deserialize
    row_result.append(deserialize(item, parent=parent))
  File "/usr/lib/python3.8/site-packages/aiogram/types/fields.py", line 112, in deserialize
    return self.base_object(conf={'parent': parent}, **value)
TypeError: __init__() got an unexpected keyword argument 'conf'

Steps to Reproduce

Just execute this code:

from aiogram import types

buttons = ['текст', 'текст', 'текст', 'текст', 'текст', 'текст','текст', 'текст','текст', 'текст', 'текст', 'текст','текст', 'текст']

markup = types.ReplyKeyboardMarkup(row_width=4, resize_keyboard=True)
markup.add(types.KeyboardButton('текст'))
markup.add(types.KeyboardButton('текст'))
markup.add(*buttons)  # or *(types.KeyboardButton(i) for i in buttons), no matter
dict_kb = markup.to_python()

types.ReplyKeyboardMarkup.to_object(dict_kb) # error

but

markup.add('текст')
markup.add('текст')
markup.add(*buttons)
dict_kb = markup.to_python()

types.ReplyKeyboardMarkup.to_object(dict_kb)

works fine

@evgfilim1 evgfilim1 added the bug Something is wrong with the framework label Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is wrong with the framework
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants