mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 17:33:44 +00:00
Fix keyboards and nullable fields.
This commit is contained in:
parent
4bf5409295
commit
f4b9bf5339
3 changed files with 14 additions and 13 deletions
|
|
@ -39,7 +39,7 @@ class BaseField(metaclass=abc.ABCMeta):
|
|||
:param instance:
|
||||
:return:
|
||||
"""
|
||||
return instance.values.get(self.alias)
|
||||
return instance.values.get(self.alias, self.default)
|
||||
|
||||
def set_value(self, instance, value, parent=None):
|
||||
"""
|
||||
|
|
@ -96,7 +96,10 @@ class Field(BaseField):
|
|||
return value
|
||||
|
||||
def deserialize(self, value, parent=None):
|
||||
if self.base_object is not None and not hasattr(value, 'base_object') and not hasattr(value, 'to_python'):
|
||||
if isinstance(value, dict) \
|
||||
and self.base_object is not None \
|
||||
and not hasattr(value, 'base_object') \
|
||||
and not hasattr(value, 'to_python'):
|
||||
return self.base_object(conf={'parent': parent}, **value)
|
||||
return value
|
||||
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ class InlineKeyboardMarkup(base.TelegramObject):
|
|||
|
||||
https://core.telegram.org/bots/api#inlinekeyboardmarkup
|
||||
"""
|
||||
inline_keyboard: 'typing.List[typing.List[InlineKeyboardButton]]' = fields.ListOfLists(base='InlineKeyboardButton',
|
||||
default=[])
|
||||
inline_keyboard: 'typing.List[typing.List[InlineKeyboardButton]]' = fields.ListOfLists(base='InlineKeyboardButton')
|
||||
|
||||
@classmethod
|
||||
def create(cls, row_width=3):
|
||||
return cls(conf={'row_width': row_width})
|
||||
def __init__(self, row_width=3, inline_keyboard=None):
|
||||
if inline_keyboard is None:
|
||||
inline_keyboard = []
|
||||
super(InlineKeyboardMarkup, self).__init__(conf={'row_width': row_width}, inline_keyboard=inline_keyboard)
|
||||
|
||||
@property
|
||||
def row_width(self):
|
||||
|
|
|
|||
|
|
@ -18,13 +18,11 @@ class ReplyKeyboardMarkup(base.TelegramObject):
|
|||
def __init__(self, keyboard: 'typing.List[typing.List[KeyboardButton]]' = None,
|
||||
resize_keyboard: base.Boolean = None,
|
||||
one_time_keyboard: base.Boolean = None,
|
||||
selective: base.Boolean = None):
|
||||
selective: base.Boolean = None,
|
||||
row_width: base.Integer = 3):
|
||||
super(ReplyKeyboardMarkup, self).__init__(keyboard=keyboard, resize_keyboard=resize_keyboard,
|
||||
one_time_keyboard=one_time_keyboard, selective=selective)
|
||||
|
||||
@classmethod
|
||||
def create(cls, row_width=3):
|
||||
return cls(conf={'row_width': row_width})
|
||||
one_time_keyboard=one_time_keyboard, selective=selective,
|
||||
conf={'row_width': row_width})
|
||||
|
||||
@property
|
||||
def row_width(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue