Skip to content

Commit 85b9b23

Browse files
committed
Fix LVHDSR.load: test other_conf to prevent mypy error
Avoid: ``` drivers/LVHDSR.py:195: error: Item "None" of "Any | None" has no attribute "get" [union-attr] drivers/LVHDSR.py:196: error: Value of type "Any | None" is not indexable [index] ``` Signed-off-by: Ronan Abhamon <ronan.abhamon@vates.fr>
1 parent 59ed5e3 commit 85b9b23

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/LVHDSR.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ def load(self, sr_uuid) -> None:
167167
self.provision = self.PROVISIONING_DEFAULT
168168

169169
self.other_conf = None
170-
has_sr_ref = self.srcmd.params.get("sr_ref")
171-
if has_sr_ref:
170+
if self.srcmd.params.get("sr_ref"):
172171
self.other_conf = self.session.xenapi.SR.get_other_config(self.sr_ref)
173172

174173
self.lvm_conf = None
@@ -182,7 +181,7 @@ def load(self, sr_uuid) -> None:
182181
opterr='Failed to initialise the LVMCache')
183182
self.lvActivator = LVActivator(self.uuid, self.lvmCache)
184183
self.journaler = Journaler(self.lvmCache)
185-
if not has_sr_ref:
184+
if not self.other_conf:
186185
return # must be a probe call
187186
# Test for thick vs thin provisioning conf parameter
188187
if 'allocation' in self.dconf:

0 commit comments

Comments
 (0)