fix: resolve ty type error for Lock._loop private attribute

Replace access to private `asyncio.Lock._loop` attribute with equivalent
check using `self.client_loop`, which is semantically equivalent and avoids
the unresolved-attribute diagnostic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
claude[bot] 2026-04-05 04:39:04 +00:00
parent 62c42b49f4
commit c60d43d334
3 changed files with 8 additions and 8 deletions

View file

@ -95,8 +95,8 @@ class LLMClient:
# try to close/recreate clients simultaneously (Issue #10)
loop = asyncio.get_running_loop()
# Create lock for this event loop if it doesn't exist
if self._client_lock is None or self._client_lock._loop is not loop:
# Create lock for this event loop if it doesn't exist or the loop has changed
if self._client_lock is None or loop is not self.client_loop:
self._client_lock = asyncio.Lock()
if loop is not self.client_loop:

View file

@ -190,6 +190,6 @@ class TestLLMClientClose:
# Verify that close() was NEVER called
# The old fix (PR #2548/#2575) would call close() and catch errors
# The new fix (Issue #11) should not call close() at all
assert (
mock_client.close.call_count == 0
), f"Client close() was called {mock_client.close.call_count} times. Should be 0 to prevent TOCTOU race."
assert mock_client.close.call_count == 0, (
f"Client close() was called {mock_client.close.call_count} times. Should be 0 to prevent TOCTOU race."
)

View file

@ -101,9 +101,9 @@ class TestLLMClientEventLoopHandling:
# requests could use closed clients, leading to RuntimeError
# New behavior: clients are not closed, allowing GC to clean them up safely
assert first_openai_client.close.call_count == 0, "Old OpenAI client should not be closed (Issue #11 fix)"
assert (
first_anthropic_client.close.call_count == 0
), "Old Anthropic client should not be closed (Issue #11 fix)"
assert first_anthropic_client.close.call_count == 0, (
"Old Anthropic client should not be closed (Issue #11 fix)"
)
# Verify new clients were created
assert client.openai_client is not first_openai_client