Skip to content

Commit d1caf94

Browse files
ydirsonNambrok
authored andcommitted
typing: add missing annotations to silence mypy notes
Signed-off-by: Yann Dirson <[email protected]>
1 parent 037a329 commit d1caf94

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/host.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ def execute_script(self, script_contents, shebang='sh', simple_output=True):
209209
finally:
210210
self.ssh(['rm', '-f', script.name])
211211

212-
def _get_xensource_inventory(self):
212+
def _get_xensource_inventory(self) -> Dict[str, str]:
213213
output = self.ssh(['cat', '/etc/xensource-inventory'])
214-
inventory: dict[str, str] = {}
214+
inventory: Dict[str, str] = {}
215215
for line in output.splitlines():
216216
key, raw_value = line.split('=')
217217
inventory[key] = raw_value.strip('\'')

lib/vm.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55
import subprocess
66
import tempfile
7-
from typing import Dict, List, Literal, Optional, overload, Union
7+
from typing import Dict, List, Literal, Optional, overload, TYPE_CHECKING, Union
88

99
import lib.commands as commands
1010
import lib.efi as efi
@@ -14,8 +14,11 @@
1414
from lib.snapshot import Snapshot
1515
from lib.vif import VIF
1616

17+
if TYPE_CHECKING:
18+
from lib.host import Host
19+
1720
class VM(BaseVM):
18-
def __init__(self, uuid, host):
21+
def __init__(self, uuid: str, host: 'Host'):
1922
super().__init__(uuid, host)
2023
self.ip: Optional[str] = None
2124
self.previous_host = None # previous host when migrated or being migrated
@@ -471,7 +474,7 @@ def clear_uefi_variables(self):
471474
"""
472475
self.param_remove('NVRAM', 'EFI-variables')
473476

474-
def get_all_efi_bins(self):
477+
def get_all_efi_bins(self) -> List[str]:
475478
magicsz = str(len(efi.EFI_HEADER_MAGIC))
476479
files = self.ssh(
477480
[
@@ -482,7 +485,7 @@ def get_all_efi_bins(self):
482485
decode=False).split(b'\n')
483486

484487
magic = efi.EFI_HEADER_MAGIC.encode('ascii')
485-
binaries: list[str] = []
488+
binaries: List[str] = []
486489
for f in files:
487490
if magic in f:
488491
# Avoid decoding an unsplit f, as some headers are not utf8

0 commit comments

Comments
 (0)