From bc50755dcff892fecd5a0c46c4bd629742320e3c Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Sun, 8 Feb 2026 21:12:49 -0600 Subject: [PATCH] fix(backend): use isinstance for type narrowing in find_block tests Replaces hasattr checks with isinstance(response, BlockListResponse) so pyright can narrow the type and see .blocks attribute. Co-Authored-By: Claude Opus 4.6 --- .../backend/api/features/chat/tools/find_block_test.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/autogpt_platform/backend/backend/api/features/chat/tools/find_block_test.py b/autogpt_platform/backend/backend/api/features/chat/tools/find_block_test.py index 9107f79a01..0f3d4cbfa5 100644 --- a/autogpt_platform/backend/backend/api/features/chat/tools/find_block_test.py +++ b/autogpt_platform/backend/backend/api/features/chat/tools/find_block_test.py @@ -9,6 +9,7 @@ from backend.api.features.chat.tools.find_block import ( COPILOT_EXCLUDED_BLOCK_TYPES, FindBlockTool, ) +from backend.api.features.chat.tools.models import BlockListResponse from backend.data.block import BlockType from ._test_data import make_session @@ -89,7 +90,7 @@ class TestFindBlockFiltering: ) # Should only return the standard block, not the INPUT block - assert hasattr(response, "blocks") + assert isinstance(response, BlockListResponse) assert len(response.blocks) == 1 assert response.blocks[0].id == "standard-block-id" @@ -133,6 +134,6 @@ class TestFindBlockFiltering: ) # Should only return normal block, not SmartDecisionMakerBlock - assert hasattr(response, "blocks") + assert isinstance(response, BlockListResponse) assert len(response.blocks) == 1 assert response.blocks[0].id == "normal-block-id"