Fix linters type check

Change-Id: Iac5caa4e559fdce9ccd8b14e76bab786feda0638
This commit is contained in:
Federico Ressi 2022-01-10 10:51:10 +01:00
parent 2ac4100069
commit ab00cdf3d4
2 changed files with 13 additions and 8 deletions

View File

@ -42,7 +42,9 @@ def setup_http_session(session, ssh_client=None):
# All known keyword arguments that could be provided to the pool manager, its # All known keyword arguments that could be provided to the pool manager, its
# pools, or the underlying connections. This is used to construct a pool key. # pools, or the underlying connections. This is used to construct a pool key.
_key_fields = tuple(poolmanager._key_fields) + ('key_ssh_client',) _key_fields = tuple(
poolmanager._key_fields # type: ignore
) + ('key_ssh_client',)
class PoolKey(collections.namedtuple("PoolKey", _key_fields)): # type: ignore class PoolKey(collections.namedtuple("PoolKey", _key_fields)): # type: ignore
@ -57,10 +59,12 @@ class PoolKey(collections.namedtuple("PoolKey", _key_fields)): # type: ignore
#: Each PoolManager makes a copy of this dictionary so they can be configured #: Each PoolManager makes a copy of this dictionary so they can be configured
#: globally here, or individually on the instance. #: globally here, or individually on the instance.
key_fn_by_scheme = { key_fn_by_scheme = {
"http": functools.partial(poolmanager._default_key_normalizer, "http": functools.partial(
PoolKey), poolmanager._default_key_normalizer, # type: ignore
"https": functools.partial(poolmanager._default_key_normalizer, PoolKey),
PoolKey), "https": functools.partial(
poolmanager._default_key_normalizer, # type: ignore
PoolKey),
} }
# pylint: enable=protected-access # pylint: enable=protected-access

View File

@ -578,13 +578,14 @@ def ssh_client(host, port=None, username=None, proxy_jump=None,
**connect_parameters) **connect_parameters)
def load_private_keys(key_filenames: typing.List[str]): def load_private_keys(key_filenames: typing.List[str]) \
pkeys = [] -> typing.List[paramiko.PKey]:
pkeys: typing.List[paramiko.PKey] = []
for filename in key_filenames: for filename in key_filenames:
if os.path.exists(filename): if os.path.exists(filename):
try: try:
with io.open(filename, 'rt') as fd: with io.open(filename, 'rt') as fd:
pkey = paramiko.RSAKey.from_private_key(fd) pkey: paramiko.PKey = paramiko.RSAKey.from_private_key(fd)
except Exception: except Exception:
LOG.error('Unable to get RSAKey private key from file: ' LOG.error('Unable to get RSAKey private key from file: '
f'{filename}', exc_info=1) f'{filename}', exc_info=1)