mypy: os_brick/encryptors/__init__.py

This coverage is somewhat limited because this
uses classes (context, keymgr) that live outside
of os-brick and therefore don't have type definitons
here.

Change-Id: I7827a870c04a7a6e02510b7909430feebb70e6f1
This commit is contained in:
Eric Harney 2022-08-17 10:17:11 -04:00
parent aa97f4455c
commit 794f006f93
2 changed files with 13 additions and 5 deletions

View File

@ -1,3 +1,5 @@
os_brick/encryptors/__init__.py
os_brick/encryptors/luks.py
os_brick/exception.py
os_brick/executor.py
os_brick/i18n.py
@ -20,4 +22,3 @@ os_brick/privileged/nvmeof.py
os_brick/privileged/rbd.py
os_brick/remotefs/remotefs.py
os_brick/initiator/linuxrbd.py
os_brick/encryptors/luks.py

View File

@ -13,11 +13,15 @@
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import annotations
from typing import Any
from oslo_log import log as logging
from oslo_utils import importutils
from oslo_utils import strutils
from os_brick.encryptors import base
from os_brick.encryptors import nop
LOG = logging.getLogger(__name__)
@ -45,11 +49,11 @@ LEGACY_PROVIDER_CLASS_TO_FORMAT_MAP = {
}
def get_volume_encryptor(root_helper,
connection_info,
def get_volume_encryptor(root_helper: str,
connection_info: dict[str, Any],
keymgr,
execute=None,
*args, **kwargs):
*args, **kwargs) -> base.VolumeEncryptor:
"""Creates a VolumeEncryptor used to encrypt the specified volume.
:param: the connection information used to attach the volume
@ -105,7 +109,10 @@ def get_volume_encryptor(root_helper,
return encryptor
def get_encryption_metadata(context, volume_api, volume_id, connection_info):
def get_encryption_metadata(context,
volume_api,
volume_id: str,
connection_info: dict[str, Any]) -> dict[str, Any]:
metadata = {}
if ('data' in connection_info and
connection_info['data'].get('encrypted', False)):