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
# 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
@ -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
#: globally here, or individually on the instance.
key_fn_by_scheme = {
"http": functools.partial(poolmanager._default_key_normalizer,
PoolKey),
"https": functools.partial(poolmanager._default_key_normalizer,
PoolKey),
"http": functools.partial(
poolmanager._default_key_normalizer, # type: ignore
PoolKey),
"https": functools.partial(
poolmanager._default_key_normalizer, # type: ignore
PoolKey),
}
# pylint: enable=protected-access

View File

@ -578,13 +578,14 @@ def ssh_client(host, port=None, username=None, proxy_jump=None,
**connect_parameters)
def load_private_keys(key_filenames: typing.List[str]):
pkeys = []
def load_private_keys(key_filenames: typing.List[str]) \
-> typing.List[paramiko.PKey]:
pkeys: typing.List[paramiko.PKey] = []
for filename in key_filenames:
if os.path.exists(filename):
try:
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:
LOG.error('Unable to get RSAKey private key from file: '
f'{filename}', exc_info=1)