From 03f51b7bca78bba8bb28940647bf9d9dbdbd0cc9 Mon Sep 17 00:00:00 2001 From: m-xim <170838360+m-xim@users.noreply.github.com> Date: Sat, 21 Mar 2026 22:11:02 +0300 Subject: [PATCH] Fix type name in error message for router type validation --- aiogram/dispatcher/router.py | 2 +- tests/test_dispatcher/test_router.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/aiogram/dispatcher/router.py b/aiogram/dispatcher/router.py index 812bf45b..72e69119 100644 --- a/aiogram/dispatcher/router.py +++ b/aiogram/dispatcher/router.py @@ -262,7 +262,7 @@ class Router: :return: """ if not isinstance(router, Router): - msg = f"router should be instance of Router not {type(router).__class__.__name__}" + msg = f"router should be instance of Router not {type(router).__name__!r}" raise ValueError(msg) router.parent_router = self return router diff --git a/tests/test_dispatcher/test_router.py b/tests/test_dispatcher/test_router.py index 1ac78480..e7884b1c 100644 --- a/tests/test_dispatcher/test_router.py +++ b/tests/test_dispatcher/test_router.py @@ -50,7 +50,9 @@ class TestRouter: def test_include_router_by_string_bad_type(self): router = Router() - with pytest.raises(ValueError, match=r"router should be instance of Router"): + with pytest.raises( + ValueError, match=r"router should be instance of Router not 'TestRouter'" + ): router.include_router(self) def test_set_parent_router_bad_type(self):