Skip to content

Commit d260bb4

Browse files
HarmenJelleZijlstra
Harmen
authored andcommitted
support for with socket.create_connection (#1429)
1 parent 2a115b1 commit d260bb4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

stdlib/2and3/socket.pyi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
# see: http://nullege.com/codes/search/socket
77
# adapted for Python 2.7 by Michal Pokorny
88
import sys
9-
from typing import Any, Tuple, List, Optional, Union, overload
9+
from typing import Any, Tuple, List, Optional, Union, overload, TypeVar
10+
1011

1112
# ----- variables and constants -----
1213

@@ -491,6 +492,7 @@ class timeout(error):
491492

492493
# TODO AF_PACKET and AF_BLUETOOTH address objects
493494

495+
_SelfT = TypeVar('_SelfT', bound=socket)
494496

495497
# ----- classes -----
496498
class socket:
@@ -505,6 +507,10 @@ class socket:
505507
def __init__(self, family: int = ..., type: int = ...,
506508
proto: int = ..., fileno: Optional[int] = ...) -> None: ...
507509

510+
if sys.version_info >= (3, 2):
511+
def __enter__(self: _SelfT) -> _SelfT: ...
512+
def __exit__(self, *args: Any) -> None: ...
513+
508514
# --- methods ---
509515
# second tuple item is an address
510516
def accept(self) -> Tuple['socket', Any]: ...

0 commit comments

Comments
 (0)