From 22f10a881c28f541754c0e153679b09e3bb31b96 Mon Sep 17 00:00:00 2001 From: JRoot Junior Date: Mon, 20 Nov 2023 22:18:37 +0200 Subject: [PATCH] Add support for nullable fields in callback data This update extends the callback data handling by adding support for nullable fields. The code now uses the Python typing structures `Optional` and `Union` to parse such fields correctly. A helper function `_check_field_is_nullable` has been added to assist in efficiently checking if a given field is nullable. --- aiogram/__init__.py | 3 ++- tests/test_fsm/test_state.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/aiogram/__init__.py b/aiogram/__init__.py index b945226f..9aedf85b 100644 --- a/aiogram/__init__.py +++ b/aiogram/__init__.py @@ -14,9 +14,10 @@ from .utils.text_decorations import html_decoration as html from .utils.text_decorations import markdown_decoration as md with suppress(ImportError): - import uvloop as _uvloop import asyncio + import uvloop as _uvloop + asyncio.set_event_loop_policy(_uvloop.EventLoopPolicy()) diff --git a/tests/test_fsm/test_state.py b/tests/test_fsm/test_state.py index dd240946..e1986079 100644 --- a/tests/test_fsm/test_state.py +++ b/tests/test_fsm/test_state.py @@ -1,6 +1,7 @@ -import pytest import sys +import pytest + from aiogram.fsm.state import State, StatesGroup, any_state PY312_OR_GREATER = sys.version_info >= (3, 12)