mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Fix getting callback params on py3.14+ (#1741)
* Add test to reproduce `TypeError: unsupported callable` on `python >=3.14` * Fix getting callback params on py3.14+ Add 1741.bugfix.rst * Code optimization
This commit is contained in:
parent
79ee135331
commit
b27ca9a45d
4 changed files with 63 additions and 5 deletions
27
tests/test_issues/test_1741_forward_ref_in_callbacks.py
Normal file
27
tests/test_issues/test_1741_forward_ref_in_callbacks.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from sys import version_info
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
|
||||
from aiogram.dispatcher.event.handler import HandlerObject
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
version_info < (3, 14), reason="Requires Python >=3.14 for TypeError on unresolved ForwardRef"
|
||||
)
|
||||
def test_forward_ref_in_callback():
|
||||
if TYPE_CHECKING:
|
||||
from aiogram.types import Message
|
||||
|
||||
def my_handler(message: Message):
|
||||
pass
|
||||
|
||||
HandlerObject(callback=my_handler)
|
||||
|
||||
|
||||
def test_forward_ref_in_callback_with_str_annotation():
|
||||
def my_handler(message: "Message"):
|
||||
pass
|
||||
|
||||
handler = HandlerObject(callback=my_handler)
|
||||
assert "message" in handler.params
|
||||
Loading…
Add table
Add a link
Reference in a new issue