Skip to content

Commit 173a739

Browse files
committed
Add some deprecation warnings
1 parent 1459224 commit 173a739

File tree

5 files changed

+39
-11
lines changed

5 files changed

+39
-11
lines changed

python_socks/async_/anyio/_proxy.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ssl
22
from typing import Any, Optional
3+
import warnings
34

45
import anyio
56

@@ -52,6 +53,12 @@ async def connect(
5253
timeout = DEFAULT_TIMEOUT
5354

5455
_stream = kwargs.get('_stream')
56+
if _stream is not None:
57+
warnings.warn(
58+
"The '_stream' argument is deprecated and will be removed in the future",
59+
DeprecationWarning,
60+
stacklevel=2,
61+
)
5562

5663
try:
5764
with anyio.fail_after(timeout):

python_socks/async_/asyncio/_proxy.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import socket
33
import sys
44
from typing import Any, Optional
5+
import warnings
56

67
from ..._types import ProxyType
78
from ..._helpers import parse_proxy_url
@@ -58,6 +59,13 @@ async def connect(
5859
timeout = DEFAULT_TIMEOUT
5960

6061
_socket = kwargs.get('_socket')
62+
if _socket is not None:
63+
warnings.warn(
64+
"The '_socket' argument is deprecated and will be removed in the future",
65+
DeprecationWarning,
66+
stacklevel=2,
67+
)
68+
6169
try:
6270
async with async_timeout.timeout(timeout):
6371
return await self._connect(
@@ -131,11 +139,7 @@ def is_uvloop_event_loop():
131139
return False
132140
return isinstance(self._loop, Loop)
133141

134-
return (
135-
sys.version_info[:2] >= (3, 8)
136-
or is_proactor_event_loop()
137-
or is_uvloop_event_loop()
138-
)
142+
return sys.version_info[:2] >= (3, 8) or is_proactor_event_loop() or is_uvloop_event_loop()
139143

140144
@property
141145
def proxy_host(self):

python_socks/async_/curio/_proxy.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import Any, Optional
2+
import warnings
23
import curio
34
import curio.io
45

@@ -47,6 +48,12 @@ async def connect(
4748
timeout = DEFAULT_TIMEOUT
4849

4950
_socket = kwargs.get('_socket')
51+
if _socket is not None:
52+
warnings.warn(
53+
"The '_socket' argument is deprecated and will be removed in the future",
54+
DeprecationWarning,
55+
stacklevel=2,
56+
)
5057

5158
try:
5259
return await curio.timeout_after(

python_socks/async_/trio/_proxy.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import Any, Optional
2+
import warnings
23
import trio
34

45
from ..._types import ProxyType
@@ -46,6 +47,12 @@ async def connect(
4647
timeout = DEFAULT_TIMEOUT
4748

4849
_socket = kwargs.get('_socket')
50+
if _socket is not None:
51+
warnings.warn(
52+
"The '_socket' argument is deprecated and will be removed in the future",
53+
DeprecationWarning,
54+
stacklevel=2,
55+
)
4956

5057
try:
5158
with trio.fail_after(timeout):
@@ -55,9 +62,7 @@ async def connect(
5562
_socket=_socket,
5663
)
5764
except trio.TooSlowError as e:
58-
raise ProxyTimeoutError(
59-
'Proxy connection timed out: {}'.format(timeout)
60-
) from e
65+
raise ProxyTimeoutError('Proxy connection timed out: {}'.format(timeout)) from e
6166

6267
async def _connect(
6368
self,

python_socks/sync/_proxy.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import socket
22
from typing import Optional, Any
3+
import warnings
34

45
from .._errors import ProxyConnectionError, ProxyTimeoutError, ProxyError
56

@@ -46,6 +47,12 @@ def connect(
4647
timeout = DEFAULT_TIMEOUT
4748

4849
_socket = kwargs.get('_socket')
50+
if _socket is not None:
51+
warnings.warn(
52+
"The '_socket' argument is deprecated and will be removed in the future",
53+
DeprecationWarning,
54+
stacklevel=2,
55+
)
4956

5057
if _socket is None:
5158
try:
@@ -81,9 +88,7 @@ def connect(
8188
return _socket
8289
except socket.timeout as e:
8390
stream.close()
84-
raise ProxyTimeoutError(
85-
'Proxy connection timed out: {}'.format(timeout)
86-
) from e
91+
raise ProxyTimeoutError('Proxy connection timed out: {}'.format(timeout)) from e
8792
except ReplyError as e:
8893
stream.close()
8994
raise ProxyError(e, error_code=e.error_code)

0 commit comments

Comments
 (0)