From e70362570b5b9daf3ec2b628e4a8f936968b0e53 Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Mon, 21 Apr 2025 11:42:12 -0400 Subject: [PATCH] nfs: minimal mypy coverage Add a minimal pass of mypy to nfs.py to help prevent errors in all of the pending code changes for this driver. More complete coverage is in Ide947c8e. Change-Id: I74bf07f0c5038834c17585245e60000ab6ac8f25 --- cinder/volume/drivers/nfs.py | 9 ++++++--- mypy-files.txt | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cinder/volume/drivers/nfs.py b/cinder/volume/drivers/nfs.py index 6e2a09792db..e6523792a26 100644 --- a/cinder/volume/drivers/nfs.py +++ b/cinder/volume/drivers/nfs.py @@ -19,6 +19,7 @@ import errno import os import tempfile import time +import typing from castellan import key_manager from os_brick.remotefs import remotefs as remotefs_brick @@ -100,9 +101,9 @@ class NfsDriver(remotefs.RemoteFSSnapDriverDistributed): self.configuration.append_config_values(nfs_opts) root_helper = utils.get_root_helper() # base bound to instance is used in RemoteFsConnector. - self.base = getattr(self.configuration, - 'nfs_mount_point_base') - self.base = os.path.realpath(self.base) + base = getattr(self.configuration, + 'nfs_mount_point_base') + self.base = os.path.realpath(base) opts = getattr(self.configuration, 'nfs_mount_options') @@ -533,7 +534,9 @@ class NfsDriver(remotefs.RemoteFSSnapDriverDistributed): data = self._stats global_capacity = data['total_capacity_gb'] + global_capacity = typing.cast(float, global_capacity) global_free = data['free_capacity_gb'] + global_free = typing.cast(float, global_free) thin_enabled = self.configuration.nfs_sparsed_volumes if thin_enabled: diff --git a/mypy-files.txt b/mypy-files.txt index 3622ebbaaa0..a96e2020500 100644 --- a/mypy-files.txt +++ b/mypy-files.txt @@ -43,6 +43,7 @@ cinder/service.py cinder/utils.py cinder/volume/__init__.py cinder/volume/api.py +cinder/volume/drivers/nfs.py cinder/volume/drivers/rbd.py cinder/volume/drivers/remotefs.py cinder/volume/flows/api/create_volume.py