Skip to content

Commit

Permalink
Update for mypy 1.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ronf committed Jul 16, 2024
1 parent b21e758 commit 3f5717e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
16 changes: 9 additions & 7 deletions asyncssh/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ def _keepalive_timer_callback(self) -> None:
self._set_keepalive_timer()
self.create_task(self._make_keepalive_request())

def _force_close(self, exc: Optional[BaseException]) -> None:
def _force_close(self, exc: Optional[Exception]) -> None:
"""Force this connection to close immediately"""

if not self._transport:
Expand Down Expand Up @@ -1313,7 +1313,7 @@ def internal_error(self, exc_info: Optional[OptExcInfo] = None,
error_logger = self.logger

error_logger.debug1('Uncaught exception', exc_info=exc_info)
self._force_close(exc_info[1])
self._force_close(cast(Exception, exc_info[1]))

def session_started(self) -> None:
"""Handle session start when opening tunneled SSH connection"""
Expand Down Expand Up @@ -3597,6 +3597,8 @@ async def public_key_auth_requested(self) -> Optional[SSHKeyPair]:
self._get_agent_keys = False

if self._get_pkcs11_keys:
assert self._pkcs11_provider is not None

pkcs11_keys = await self._loop.run_in_executor(
None, load_pkcs11_keys, self._pkcs11_provider, self._pkcs11_pin)

Expand Down Expand Up @@ -7677,7 +7679,7 @@ class SSHClientConnectionOptions(SSHConnectionOptions):
:type agent_identities:
*see* :ref:`SpecifyingPublicKeys` and :ref:`SpecifyingCertificates`
:type agent_forwarding: `bool`
:type pkcs11_provider: `str`
:type pkcs11_provider: `str` or `None`
:type pkcs11_pin: `str`
:type client_version: `str`
:type kex_algs: `str` or `list` of `str`
Expand Down Expand Up @@ -7738,7 +7740,7 @@ class SSHClientConnectionOptions(SSHConnectionOptions):
agent_path: Optional[str]
agent_identities: Optional[Sequence[bytes]]
agent_forward_path: Optional[str]
pkcs11_provider: Optional[FilePath]
pkcs11_provider: Optional[str]
pkcs11_pin: Optional[str]
command: Optional[str]
subsystem: Optional[str]
Expand Down Expand Up @@ -7805,7 +7807,7 @@ def prepare(self, # type: ignore
agent_path: DefTuple[Optional[str]] = (),
agent_identities: DefTuple[Optional[IdentityListArg]] = (),
agent_forwarding: DefTuple[bool] = (),
pkcs11_provider: DefTuple[Optional[FilePath]] = (),
pkcs11_provider: DefTuple[Optional[str]] = (),
pkcs11_pin: Optional[str] = None,
command: DefTuple[Optional[str]] = (),
subsystem: Optional[str] = None, env: DefTuple[_Env] = (),
Expand Down Expand Up @@ -7962,9 +7964,9 @@ def prepare(self, # type: ignore

if pkcs11_provider == ():
pkcs11_provider = \
cast(Optional[FilePath], config.get('PKCS11Provider'))
cast(Optional[str], config.get('PKCS11Provider'))

pkcs11_provider: Optional[FilePath]
pkcs11_provider: Optional[str]

if ignore_encrypted == ():
ignore_encrypted = client_keys == ()
Expand Down
3 changes: 2 additions & 1 deletion asyncssh/saslprep.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import stringprep
# pylint: enable=deprecated-module
from typing import Callable, Optional, Sequence
from typing_extensions import Literal
import unicodedata


Expand Down Expand Up @@ -62,7 +63,7 @@ def _check_bidi(s: str) -> None:

def _stringprep(s: str, check_unassigned: bool,
mapping: Optional[Callable[[str], str]],
normalization: str,
normalization: Literal['NFC', 'NFD', 'NFKC', 'NFKD'],
prohibited: Sequence[Callable[[str], bool]],
bidi: bool) -> str:
"""Implement a stringprep profile as defined in RFC 3454"""
Expand Down

0 comments on commit 3f5717e

Please sign in to comment.