Fix explanation_parse_mode validation

This commit is contained in:
Alex Root Junior 2020-06-27 16:59:21 +03:00
parent 360fdfc4d8
commit 46d01a6ae7
3 changed files with 6 additions and 4 deletions

View file

@ -1214,7 +1214,7 @@ class Bot(ContextInstanceMixin["Bot"]):
allows_multiple_answers: Optional[bool] = None,
correct_option_id: Optional[int] = None,
explanation: Optional[str] = None,
explanation_parse_mode: Optional[str] = None,
explanation_parse_mode: Optional[str] = UNSET,
open_period: Optional[int] = None,
close_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None,
is_closed: Optional[bool] = None,

View file

@ -56,8 +56,9 @@ class TelegramMethod(abc.ABC, BaseModel, Generic[T]):
a model initialization from `Bot.method_name`, so we must take care of it and
remove it before fields validation.
"""
if "parse_mode" in values and values["parse_mode"] is UNSET:
values.pop("parse_mode")
for parse_mode_attribute in {"parse_mode", "explanation_parse_mode"}:
if parse_mode_attribute in values and values[parse_mode_attribute] is UNSET:
values.pop(parse_mode_attribute)
return values
@property

View file

@ -9,6 +9,7 @@ from ..types import (
Message,
ReplyKeyboardMarkup,
ReplyKeyboardRemove,
UNSET,
)
from .base import Request, TelegramMethod, prepare_parse_mode
@ -44,7 +45,7 @@ class SendPoll(TelegramMethod[Message]):
explanation: Optional[str] = None
"""Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a
quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing"""
explanation_parse_mode: Optional[str] = None
explanation_parse_mode: Optional[str] = UNSET
"""Mode for parsing entities in the explanation. See formatting options for more details."""
open_period: Optional[int] = None
"""Amount of time in seconds the poll will be active after creation, 5-600. Can't be used