Skip to content

Commit 21348a7

Browse files
author
RJ Lopez
committed
fix(test): resolve BaseExceptionGroup name error and Pyright warnings
1 parent 35e682a commit 21348a7

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

tests/client/test_session_group.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
from __future__ import annotations
2+
13
import contextlib
24
import socket
5+
import sys
36
from unittest import mock
47

8+
if sys.version_info < (3, 11):
9+
from exceptiongroup import BaseExceptionGroup # noqa: A004
10+
511
import httpx
612
import pytest
713

@@ -414,7 +420,7 @@ def _walk(e: BaseException | None) -> bool:
414420
if isinstance(e, RuntimeError) and "cancel scope" in str(e).lower():
415421
return True
416422
if isinstance(e, BaseExceptionGroup):
417-
if any(_walk(child) for child in e.exceptions):
423+
if any(_walk(child) for child in e.exceptions): # type: ignore
418424
return True
419425
return _walk(e.__cause__) or _walk(e.__context__)
420426

@@ -438,10 +444,10 @@ async def test_unreachable_streamable_http_error_is_catchable() -> None:
438444
async with ClientSessionGroup() as group:
439445
try:
440446
await group.connect_to_server(server_params)
441-
except BaseException as inner: # noqa: BLE001
447+
except BaseException as inner:
442448
# Expected post-fix: real ConnectError lands here.
443449
caught = inner
444-
except BaseException as outer: # noqa: BLE001
450+
except BaseException as outer:
445451
# If we land here, the error escaped past the inner handler --
446452
# that is the regression case (masking RuntimeError surfacing
447453
# from __aexit__ instead of the real ConnectError propagating).

0 commit comments

Comments
 (0)