Skip to content

Commit 227ae9f

Browse files
committed
Fix some type annotations
1 parent 619590a commit 227ae9f

File tree

16 files changed

+21
-23
lines changed

16 files changed

+21
-23
lines changed

python_socks/async_/anyio/_connect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
from typing import Optional
12
import anyio
23
import anyio.abc
34

45

56
async def connect_tcp(
67
host: str,
78
port: int,
8-
local_host: str = None,
9+
local_host: Optional[str] = None,
910
) -> anyio.abc.SocketStream:
1011

1112
return await anyio.connect_tcp(

python_socks/async_/anyio/_proxy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,6 @@ def create(cls, *args, **kwargs): # for backward compatibility
130130
return cls(*args, **kwargs)
131131

132132
@classmethod
133-
def from_url(cls, url: str, **kwargs):
133+
def from_url(cls, url: str, **kwargs) -> 'AnyioProxy':
134134
url_args = parse_proxy_url(url)
135135
return cls(*url_args, **kwargs)

python_socks/async_/anyio/v2/_connect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from typing import Optional
12
import anyio
23
import anyio.abc
34
from ._stream import AnyioSocketStream
@@ -6,7 +7,7 @@
67
async def connect_tcp(
78
host: str,
89
port: int,
9-
local_host: str = None,
10+
local_host: Optional[str] = None,
1011
) -> AnyioSocketStream:
1112
s = await anyio.connect_tcp(
1213
remote_host=host,

python_socks/async_/anyio/v2/_proxy.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ async def connect(
5959
dest_ssl=dest_ssl,
6060
)
6161
except TimeoutError as e:
62-
raise ProxyTimeoutError(
63-
'Proxy connection timed out: {}'.format(timeout)
64-
) from e
62+
raise ProxyTimeoutError('Proxy connection timed out: {}'.format(timeout)) from e
6563

6664
async def _connect(
6765
self,
@@ -127,6 +125,6 @@ def create(cls, *args, **kwargs): # for backward compatibility
127125
return cls(*args, **kwargs)
128126

129127
@classmethod
130-
def from_url(cls, url: str, **kwargs):
128+
def from_url(cls, url: str, **kwargs) -> 'AnyioProxy':
131129
url_args = parse_proxy_url(url)
132130
return cls(*url_args, **kwargs)

python_socks/async_/asyncio/_connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def connect_tcp(
2323
if is_ipv6_address(host):
2424
address = (host, port, 0, 0) # to fix OSError: [WinError 10022]
2525
else:
26-
address = (host, port)
26+
address = (host, port) # type: ignore[assignment]
2727

2828
await loop.sock_connect(sock=sock, address=address)
2929
return sock

python_socks/async_/asyncio/_proxy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,6 @@ def create(cls, *args, **kwargs): # for backward compatibility
129129
return cls(*args, **kwargs)
130130

131131
@classmethod
132-
def from_url(cls, url: str, **kwargs):
132+
def from_url(cls, url: str, **kwargs) -> 'AsyncioProxy':
133133
url_args = parse_proxy_url(url)
134134
return cls(*url_args, **kwargs)

python_socks/async_/asyncio/v2/_connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async def connect_tcp(
1616
reader, writer = await asyncio.open_connection(
1717
host=host,
1818
port=port,
19-
**kwargs,
19+
**kwargs, # type: ignore
2020
)
2121

2222
return AsyncioSocketStream(

python_socks/async_/asyncio/v2/_proxy.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ async def connect(
8080
dest_ssl=dest_ssl,
8181
)
8282
except asyncio.TimeoutError as e:
83-
raise ProxyTimeoutError(
84-
'Proxy connection timed out: {}'.format(timeout)
85-
) from e
83+
raise ProxyTimeoutError('Proxy connection timed out: {}'.format(timeout)) from e
8684

8785
async def _connect(
8886
self,
@@ -149,6 +147,6 @@ def create(cls, *args, **kwargs): # for backward compatibility
149147
return cls(*args, **kwargs)
150148

151149
@classmethod
152-
def from_url(cls, url: str, **kwargs):
150+
def from_url(cls, url: str, **kwargs) -> 'AsyncioProxy':
153151
url_args = parse_proxy_url(url)
154152
return cls(*url_args, **kwargs)

python_socks/async_/curio/_proxy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,6 @@ def create(cls, *args, **kwargs): # for backward compatibility
123123
return cls(*args, **kwargs)
124124

125125
@classmethod
126-
def from_url(cls, url: str, **kwargs):
126+
def from_url(cls, url: str, **kwargs) -> 'CurioProxy':
127127
url_args = parse_proxy_url(url)
128128
return cls(*url_args, **kwargs)

python_socks/async_/trio/_proxy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,6 @@ def create(cls, *args, **kwargs): # for backward compatibility
122122
return cls(*args, **kwargs)
123123

124124
@classmethod
125-
def from_url(cls, url: str, **kwargs):
125+
def from_url(cls, url: str, **kwargs) -> 'TrioProxy':
126126
url_args = parse_proxy_url(url)
127127
return cls(*url_args, **kwargs)

0 commit comments

Comments
 (0)