From 33366c74c724e7de8aa337ce4c681d2ba3d04ccc Mon Sep 17 00:00:00 2001 From: Juan Calzada Date: Mon, 5 Oct 2026 17:07:40 +0200 Subject: [PATCH] fix(asyncio): use asyncio StateContext in StateMiddleware --- telebot/states/asyncio/middleware.py | 2 +- tests/test_async_telebot.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/telebot/states/asyncio/middleware.py b/telebot/states/asyncio/middleware.py index 675b7b462..2bbd29654 100644 --- a/telebot/states/asyncio/middleware.py +++ b/telebot/states/asyncio/middleware.py @@ -1,6 +1,6 @@ from telebot.asyncio_handler_backends import BaseMiddleware from telebot.async_telebot import AsyncTeleBot -from telebot.states.sync.context import StateContext +from telebot.states.asyncio.context import StateContext from telebot.util import update_types from telebot import types diff --git a/tests/test_async_telebot.py b/tests/test_async_telebot.py index 2b72da6c0..0dcd55546 100644 --- a/tests/test_async_telebot.py +++ b/tests/test_async_telebot.py @@ -238,3 +238,11 @@ async def fake_sleep(_seconds): assert calls["n"] == budget, ( f"Expected {budget} total attempts, got {calls['n']}" ) + + +def test_async_state_middleware_uses_async_context(): + from telebot.states.asyncio.middleware import StateMiddleware, StateContext + from telebot.states.asyncio.context import StateContext as AsyncStateContext + + assert StateContext is AsyncStateContext, "StateMiddleware must use asyncio.context.StateContext" +