mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
#901 Fixed false-positive coercing of Union types in API methods
This commit is contained in:
parent
6ad242399b
commit
dab4e26f1c
3 changed files with 8 additions and 1 deletions
1
CHANGES/901.bugfix.rst
Normal file
1
CHANGES/901.bugfix.rst
Normal file
|
|
@ -0,0 +1 @@
|
|||
Fixed false-positive coercing of Union types in API methods
|
||||
|
|
@ -46,6 +46,7 @@ class TelegramMethod(abc.ABC, BaseModel, Generic[TelegramType]):
|
|||
allow_population_by_field_name = True
|
||||
arbitrary_types_allowed = True
|
||||
orm_mode = True
|
||||
smart_union = True # https://github.com/aiogram/aiogram/issues/901
|
||||
|
||||
@root_validator(pre=True)
|
||||
def remove_unset(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import datetime
|
|||
import pytest
|
||||
|
||||
from aiogram.methods import Request, SendMessage
|
||||
from aiogram.types import Chat, Message
|
||||
from aiogram.types import Chat, ForceReply, Message
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
|
@ -43,3 +43,8 @@ class TestSendMessage:
|
|||
request: Request = bot.get_request()
|
||||
assert request.method == "sendMessage"
|
||||
assert response == prepare_result.result
|
||||
|
||||
async def test_force_reply(self):
|
||||
# https://github.com/aiogram/aiogram/issues/901
|
||||
method = SendMessage(text="test", chat_id=42, reply_markup=ForceReply())
|
||||
assert isinstance(method.reply_markup, ForceReply)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue