From 3f5717e026f951a2e38a252abb623d2192fcb07e Mon Sep 17 00:00:00 2001 From: Ron Frederick Date: Mon, 15 Jul 2024 17:00:39 -0700 Subject: [PATCH] Update for mypy 1.10.1 --- asyncssh/connection.py | 16 +++++++++------- asyncssh/saslprep.py | 3 ++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/asyncssh/connection.py b/asyncssh/connection.py index 4fe6b78..665075f 100644 --- a/asyncssh/connection.py +++ b/asyncssh/connection.py @@ -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: @@ -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""" @@ -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) @@ -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` @@ -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] @@ -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] = (), @@ -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 == () diff --git a/asyncssh/saslprep.py b/asyncssh/saslprep.py index 569e502..890abd4 100644 --- a/asyncssh/saslprep.py +++ b/asyncssh/saslprep.py @@ -32,6 +32,7 @@ import stringprep # pylint: enable=deprecated-module from typing import Callable, Optional, Sequence +from typing_extensions import Literal import unicodedata @@ -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"""