Skip to content

Commit e741635

Browse files
authored
Use Self in TestClient.__enter__ (#2951)
1 parent 739ea49 commit e741635

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

starlette/testclient.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
else: # pragma: no cover
3636
from typing_extensions import TypeGuard
3737

38+
if sys.version_info >= (3, 11): # pragma: no cover
39+
from typing import Self
40+
else: # pragma: no cover
41+
from typing_extensions import Self
42+
3843
try:
3944
import httpx
4045
except ModuleNotFoundError: # pragma: no cover
@@ -667,7 +672,7 @@ def websocket_connect(
667672

668673
return session
669674

670-
def __enter__(self) -> TestClient:
675+
def __enter__(self) -> Self:
671676
with contextlib.ExitStack() as stack:
672677
self.portal = portal = stack.enter_context(anyio.from_thread.start_blocking_portal(**self.async_backend))
673678

0 commit comments

Comments
 (0)