mypy: Annotate utils.get_device_size

Add annotations for parameters of this method.

Change-Id: I3149e0067f97d373333e0901e49725401fc6c068
This commit is contained in:
Eric Harney 2022-11-15 13:03:21 -05:00
parent 0639af4fc8
commit dc953012b7
2 changed files with 7 additions and 2 deletions

View File

@ -1195,7 +1195,11 @@ class NVMeOFConnector(base.BaseLinuxConnector):
LOG.info('Wait 5 seconds and return whatever size is present')
time.sleep(5)
return utils.get_device_size(self, device_path)
size = utils.get_device_size(self, device_path)
if size is None:
raise exception.BrickException(
'get_device_size returned non-numeric size')
return size
# ####### RAID methods ########

View File

@ -25,6 +25,7 @@ from oslo_concurrency import processutils
from oslo_log import log as logging
from oslo_utils import strutils
from os_brick import executor
from os_brick.i18n import _
from os_brick.privileged import nvmeof as priv_nvme
from os_brick.privileged import rootwrap as priv_rootwrap
@ -400,7 +401,7 @@ def connect_volume_undo_prepare_result(
return decorator
def get_device_size(executor, device):
def get_device_size(executor: executor.Executor, device: str) -> Optional[int]:
"""Get the size in bytes of a volume."""
(out, _err) = executor._execute('blockdev', '--getsize64',
device, run_as_root=True,