Skip to content

Commit fc0d3cf

Browse files
committed
Fix latest mypy issues
1 parent b99e8d5 commit fc0d3cf

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

asyncssh/connection.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
from pathlib import Path
3838
from types import TracebackType
3939
from typing import TYPE_CHECKING, Any, AnyStr, Awaitable, Callable, Dict
40-
from typing import List, Mapping, Optional, Sequence, Set, Tuple, Type
41-
from typing import TypeVar, Union, cast
40+
from typing import Generic, List, Mapping, Optional, Sequence, Set, Tuple
41+
from typing import Type, TypeVar, Union, cast
4242
from typing_extensions import Protocol, Self
4343

4444
from .agent import SSHAgentClient, SSHAgentListener
@@ -395,7 +395,7 @@ def close(self) -> None:
395395
return cast(_Conn, cast(_ProxyCommandTunnel, tunnel).get_conn())
396396

397397

398-
async def _open_tunnel(tunnels: object, options: '_Options',
398+
async def _open_tunnel(tunnels: object, options: _Options,
399399
config: DefTuple[ConfigPaths]) -> \
400400
Optional['SSHClientConnection']:
401401
"""Parse and open connection to tunnel over"""
@@ -432,7 +432,7 @@ async def _open_tunnel(tunnels: object, options: '_Options',
432432
return None
433433

434434

435-
async def _connect(options: '_Options', config: DefTuple[ConfigPaths],
435+
async def _connect(options: _Options, config: DefTuple[ConfigPaths],
436436
loop: asyncio.AbstractEventLoop, flags: int,
437437
sock: Optional[socket.socket],
438438
conn_factory: Callable[[], _Conn], msg: str) -> _Conn:
@@ -517,7 +517,7 @@ async def _connect(options: '_Options', config: DefTuple[ConfigPaths],
517517
await conn.wait_closed()
518518

519519

520-
async def _listen(options: '_Options', config: DefTuple[ConfigPaths],
520+
async def _listen(options: _Options, config: DefTuple[ConfigPaths],
521521
loop: asyncio.AbstractEventLoop, flags: int,
522522
backlog: int, sock: Optional[socket.socket],
523523
reuse_address: bool, reuse_port: bool,
@@ -7151,7 +7151,7 @@ async def open_agent_connection(self) -> \
71517151
return SSHReader[bytes](session, chan), SSHWriter[bytes](session, chan)
71527152

71537153

7154-
class SSHConnectionOptions(Options):
7154+
class SSHConnectionOptions(Options, Generic[_Options]):
71557155
"""SSH connection options"""
71567156

71577157
config: SSHConfig
@@ -7189,12 +7189,12 @@ class SSHConnectionOptions(Options):
71897189
keepalive_internal: float
71907190
keepalive_count_max: int
71917191

7192-
def __init__(self, options: Optional['_Options'] = None, **kwargs: object):
7192+
def __init__(self, options: Optional[_Options] = None, **kwargs: object):
71937193
last_config = options.config if options else None
71947194
super().__init__(options=options, last_config=last_config, **kwargs)
71957195

71967196
@classmethod
7197-
async def construct(cls, options: Optional['_Options'] = None,
7197+
async def construct(cls, options: Optional[_Options] = None,
71987198
**kwargs: object) -> _Options:
71997199
"""Construct a new options object from within an async task"""
72007200

@@ -7355,9 +7355,7 @@ def _split_cname_patterns(
73557355
elif isinstance(rekey_bytes, str):
73567356
rekey_bytes = parse_byte_count(rekey_bytes)
73577357

7358-
rekey_bytes: int
7359-
7360-
if rekey_bytes <= 0:
7358+
if cast(int, rekey_bytes) <= 0:
73617359
raise ValueError('Rekey bytes cannot be negative or zero')
73627360

73637361
if rekey_seconds == ():
@@ -7368,9 +7366,7 @@ def _split_cname_patterns(
73687366
elif isinstance(rekey_seconds, str):
73697367
rekey_seconds = parse_time_interval(rekey_seconds)
73707368

7371-
rekey_seconds: float
7372-
7373-
if rekey_seconds and rekey_seconds <= 0:
7369+
if rekey_seconds and cast(float, rekey_seconds) <= 0:
73747370
raise ValueError('Rekey seconds cannot be negative or zero')
73757371

73767372
if isinstance(connect_timeout, str):
@@ -7394,8 +7390,8 @@ def _split_cname_patterns(
73947390
if keepalive_count_max <= 0:
73957391
raise ValueError('Keepalive count max cannot be negative or zero')
73967392

7397-
self.rekey_bytes = rekey_bytes
7398-
self.rekey_seconds = rekey_seconds
7393+
self.rekey_bytes = cast(int, rekey_bytes)
7394+
self.rekey_seconds = cast(float, rekey_seconds)
73997395
self.connect_timeout = connect_timeout or None
74007396
self.login_timeout = login_timeout
74017397
self.keepalive_interval = keepalive_interval

asyncssh/sftp.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4341,6 +4341,8 @@ async def makedirs(self, path: _SFTPPath, attrs: SFTPAttrs = SFTPAttrs(),
43414341
parts = path.split(b'/')
43424342
last = len(parts) - 1
43434343

4344+
exc: Type[SFTPError]
4345+
43444346
for i, part in enumerate(parts):
43454347
curpath = posixpath.join(curpath, part)
43464348

0 commit comments

Comments
 (0)