From 5cb02f43573c343438a983f3295a159b3a2347da Mon Sep 17 00:00:00 2001 From: uditDewan Date: Sat, 11 Jul 2026 19:31:35 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20Use=20cast=20for=20the?= =?UTF-8?q?=20fake=20rebuild=20lock=20to=20satisfy=20ty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_included_router_concurrent_rebuild.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_included_router_concurrent_rebuild.py b/tests/test_included_router_concurrent_rebuild.py index 1ab3a0e9c..507a539fd 100644 --- a/tests/test_included_router_concurrent_rebuild.py +++ b/tests/test_included_router_concurrent_rebuild.py @@ -1,6 +1,6 @@ import sys import threading -from typing import Any +from typing import Any, cast from fastapi import APIRouter, FastAPI from fastapi.routing import _IncludedRouter @@ -92,9 +92,10 @@ def test_candidates_rebuilt_while_waiting_for_lock_are_reused() -> None: app.include_router(router) included = get_included_router(app) cache: list = [] - included._rebuild_lock = StampCacheOnEnter( # type: ignore[assignment] + fake_lock = StampCacheOnEnter( included, "_effective_candidates", "_effective_candidates_version", cache ) + included._rebuild_lock = cast(threading.Lock, fake_lock) assert included.effective_candidates() is cache @@ -105,10 +106,11 @@ def test_low_priority_routes_rebuilt_while_waiting_for_lock_are_reused() -> None app.include_router(router) included = get_included_router(app) cache: list = [] - included._rebuild_lock = StampCacheOnEnter( # type: ignore[assignment] + fake_lock = StampCacheOnEnter( included, "_effective_low_priority_routes", "_effective_low_priority_routes_version", cache, ) + included._rebuild_lock = cast(threading.Lock, fake_lock) assert included.effective_low_priority_routes() is cache