Skip to content

Commit a2ea28d

Browse files
glehmannydirson
authored andcommitted
param_get() may also return a bool
Signed-off-by: Gaëtan Lehmann <[email protected]>
1 parent 008ce7e commit a2ea28d

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lib/basevm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22

3-
from typing import Any, Optional, TYPE_CHECKING
3+
from typing import Any, Optional, TYPE_CHECKING, Union
44

55
import lib.commands as commands
66
if TYPE_CHECKING:
@@ -20,7 +20,7 @@ def __init__(self, uuid, host: 'lib.host.Host'):
2020
self.host = host
2121

2222
def param_get(self, param_name: str, key: Optional[str] = None,
23-
accept_unknown_key: bool = False) -> Optional[str]:
23+
accept_unknown_key: bool = False) -> Union[str, bool, None]:
2424
return _param_get(self.host, self.xe_prefix, self.uuid,
2525
param_name, key, accept_unknown_key)
2626

lib/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def strtobool(str):
158158
raise ValueError("invalid truth value '{}'".format(str))
159159

160160
def _param_get(host: 'lib.host.Host', xe_prefix: str, uuid: str, param_name: str, key: Optional[str] = None,
161-
accept_unknown_key=False) -> Optional[str]:
161+
accept_unknown_key=False) -> Union[str, bool, None]:
162162
""" Common implementation for param_get. """
163163
args: Dict[str, Union[str, bool]] = {'uuid': uuid, 'param-name': param_name}
164164
if key is not None:

lib/vm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
import subprocess
44
import tempfile
5-
from typing import List, Literal, Optional, Union, overload
5+
from typing import List, Literal, Optional, Union, cast, overload
66

77
import lib.commands as commands
88
import lib.efi as efi
@@ -72,7 +72,7 @@ def reboot(self, force=False, verify=False):
7272
return ret
7373

7474
def try_get_and_store_ip(self):
75-
ip = self.param_get('networks', '0/ip', accept_unknown_key=True)
75+
ip = cast(str, self.param_get('networks', '0/ip', accept_unknown_key=True))
7676

7777
# An IP that starts with 169.254. is not a real routable IP.
7878
# VMs may return such an IP before they get an actual one from DHCP.

0 commit comments

Comments
 (0)