Skip to content

Commit

Permalink
Fix a few lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ronf committed Oct 13, 2024
1 parent 416db0e commit fa01aab
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 26 deletions.
19 changes: 10 additions & 9 deletions asyncssh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
from . import sk_eddsa, sk_ecdsa, eddsa, ecdsa, rsa, dsa, kex_dh, kex_rsa

__all__ = [
'__author__', '__author_email__', '__url__', '__version__',
'BreakReceived', 'BytesOrStr', 'ChannelListenError',
'ChannelOpenError', 'CompressionError', 'ConfigParseError',
'ConnectionLost', 'DEVNULL', 'DataType', 'DisconnectError', 'Error',
Expand All @@ -136,15 +137,15 @@
'SFTPDirNotEmpty', 'SFTPEOFError', 'SFTPError', 'SFTPFailure',
'SFTPFileAlreadyExists', 'SFTPFileCorrupt', 'SFTPFileIsADirectory',
'SFTPGroupInvalid', 'SFTPInvalidFilename', 'SFTPInvalidHandle',
'SFTPInvalidParameter', 'SFTPLinkLoop', 'SFTPLockConflict', 'SFTPName',
'SFTPNoConnection', 'SFTPNoMatchingByteRangeLock', 'SFTPNoMedia',
'SFTPNoSpaceOnFilesystem', 'SFTPNoSuchFile', 'SFTPNoSuchPath',
'SFTPNotADirectory', 'SFTPOpUnsupported', 'SFTPOwnerInvalid',
'SFTPPermissionDenied', 'SFTPQuotaExceeded', 'SFTPServer',
'SFTPServerFactory', 'SFTPUnknownPrincipal', 'SFTPVFSAttrs',
'SFTPWriteProtect', 'SSHAcceptor', 'SSHAgentClient', 'SSHAgentKeyPair',
'SSHAuthorizedKeys', 'SSHCertificate', 'SSHClient', 'SSHClientChannel',
'SSHClientConnection', 'SSHClientConnectionOptions',
'SFTPInvalidParameter', 'SFTPLimits', 'SFTPLinkLoop', 'SFTPLockConflict',
'SFTPName', 'SFTPNoConnection', 'SFTPNoMatchingByteRangeLock',
'SFTPNoMedia', 'SFTPNoSpaceOnFilesystem', 'SFTPNoSuchFile',
'SFTPNoSuchPath', 'SFTPNotADirectory', 'SFTPOpUnsupported',
'SFTPOwnerInvalid', 'SFTPPermissionDenied', 'SFTPQuotaExceeded',
'SFTPServer', 'SFTPServerFactory', 'SFTPUnknownPrincipal', 'SFTPVFSAttrs',
'SFTPWriteProtect', 'SSHAcceptHandler', 'SSHAcceptor', 'SSHAgentClient',
'SSHAgentKeyPair', 'SSHAuthorizedKeys', 'SSHCertificate', 'SSHClient',
'SSHClientChannel', 'SSHClientConnection', 'SSHClientConnectionOptions',
'SSHClientProcess', 'SSHClientSession', 'SSHCompletedProcess',
'SSHForwarder', 'SSHKey', 'SSHKeyPair', 'SSHKnownHosts',
'SSHLineEditorChannel', 'SSHListener', 'SSHReader', 'SSHServer',
Expand Down
16 changes: 4 additions & 12 deletions asyncssh/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"""SSH agent client"""

import asyncio
import errno
import os
import sys
from types import TracebackType
Expand Down Expand Up @@ -58,17 +57,10 @@ async def wait_closed(self) -> None:
"""Wait for the connection to the SSH agent to close"""


try:
if sys.platform == 'win32': # pragma: no cover
from .agent_win32 import open_agent
else:
from .agent_unix import open_agent
except ImportError as _exc: # pragma: no cover
async def open_agent(agent_path: str) -> \
Tuple[AgentReader, AgentWriter]:
"""Dummy function if we're unable to import agent support"""

raise OSError(errno.ENOENT, 'Agent support unavailable: %s' % str(_exc))
if sys.platform == 'win32': # pragma: no cover
from .agent_win32 import open_agent
else:
from .agent_unix import open_agent


class _SupportsOpenAgentConnection(Protocol):
Expand Down
2 changes: 1 addition & 1 deletion asyncssh/auth_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def _add_permitopen(self, option: str, value: str) -> None:
host = host[1:-1]

port = None if port_str == '*' else int(port_str)
except:
except ValueError:
raise ValueError('Illegal permitopen value: %s' % value) from None

permitted_opens = cast(Set[Tuple[str, Optional[int]]],
Expand Down
13 changes: 13 additions & 0 deletions asyncssh/crypto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,16 @@
from .x509 import generate_x509_certificate, import_x509_certificate
except (ImportError, AttributeError): # pragma: no cover
pass

__all__ = [
'BasicCipher', 'ChachaCipher', 'CryptoKey', 'Curve25519DH', 'Curve448DH',
'DH', 'DSAPrivateKey', 'DSAPublicKey', 'ECDH', 'ECDSAPrivateKey',
'ECDSAPublicKey', 'EdDSAPrivateKey', 'EdDSAPublicKey', 'GCMCipher', 'PQDH',
'PyCAKey', 'RSAPrivateKey', 'RSAPublicKey', 'chacha_available',
'curve25519_available', 'curve448_available', 'X509Certificate',
'X509Name', 'X509NamePattern', 'ed25519_available', 'ed448_available',
'generate_x509_certificate', 'get_cipher_params', 'import_x509_certificate',
'lookup_ec_curve_by_params', 'mlkem_available', 'pbkdf2_hmac',
'register_cipher', 'sntrup_available', 'umac32', 'umac64', 'umac96',
'umac128'
]
2 changes: 1 addition & 1 deletion asyncssh/scp.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ async def run(self, dstpath: _SCPPath) -> None:
dstpath))
else:
await self._recv_files(b'', dstpath)
except asyncio.CancelledError as exc:
except asyncio.CancelledError:
cancelled = True
except (OSError, SFTPError, ValueError) as exc:
self.handle_error(exc)
Expand Down
4 changes: 2 additions & 2 deletions asyncssh/sftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2660,7 +2660,7 @@ async def start(self) -> None:
rcvd_extensions.append((name, data))
except PacketDecodeError as exc:
raise SFTPBadMessage(str(exc)) from None
except SFTPError as exc:
except SFTPError:
raise
except ConnectionLost as exc:
raise SFTPConnectionLost(str(exc)) from None
Expand Down Expand Up @@ -5715,7 +5715,7 @@ async def _process_packet(self, pkttype: int, pktid: int,
str(exc.reason))

response = exc.encode(self._version)
except NotImplementedError as exc:
except NotImplementedError:
assert handler is not None

return_type = FXP_STATUS
Expand Down
2 changes: 1 addition & 1 deletion asyncssh/sk.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def sk_enroll(alg: int, application: bytes, user: str,
raise ValueError('Invalid PIN') from None
else:
raise ValueError(str(exc)) from None
except ValueError as exc:
except ValueError:
try:
return _ctap1_enroll(dev, alg, application)
except ApduError as exc:
Expand Down

0 comments on commit fa01aab

Please sign in to comment.