Skip to content

Commit 9bb906a

Browse files
committed
Fix type checker errors by asserting config option values are not None
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent e939bfb commit 9bb906a

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

conftest.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import tempfile
99

1010
import git
11+
from cryptography.hazmat.primitives.serialization import SSHCertPrivateKeyTypes
1112
from packaging import version
1213

1314
import lib.config as global_config
@@ -105,7 +106,9 @@ def pytest_addoption(parser: pytest.Parser) -> None:
105106

106107
def pytest_configure(config: pytest.Config) -> None:
107108
global_config.ignore_ssh_banner = config.getoption('--ignore-ssh-banner')
108-
global_config.ssh_output_max_lines = int(config.getoption('--ssh-output-max-lines'))
109+
ssh_output_max_lines = config.getoption('--ssh-output-max-lines')
110+
assert ssh_output_max_lines is not None
111+
global_config.ssh_output_max_lines = int(ssh_output_max_lines)
109112

110113
def pytest_generate_tests(metafunc: pytest.Metafunc) -> None:
111114
if "vm_ref" in metafunc.fixturenames:
@@ -116,6 +119,7 @@ def pytest_generate_tests(metafunc: pytest.Metafunc) -> None:
116119

117120
if "image_format" in metafunc.fixturenames:
118121
image_format = metafunc.config.getoption("image_format")
122+
assert image_format is not None
119123
if len(image_format) == 0:
120124
image_format = ["vhd"] # Not giving image-format will default to doing tests on vhd
121125
metafunc.parametrize("image_format", image_format, scope="session")
@@ -223,6 +227,7 @@ def cleanup_hosts() -> None:
223227

224228
# a list of master hosts, each from a different pool
225229
hosts_args = pytestconfig.getoption("hosts")
230+
assert hosts_args is not None
226231
hosts_split = [hostlist.split(',') for hostlist in hosts_args]
227232
hostname_list = list(itertools.chain(*hosts_split))
228233

@@ -376,8 +381,10 @@ def _parse_disk_option(option_text: str) -> tuple[HostAddress, list[DiskDevName]
376381
devices = disks_string.split(',') if disks_string else []
377382
return host_address, devices
378383

384+
disks = pytestconfig.getoption("disks")
385+
assert disks is not None
379386
cli_disks = dict(_parse_disk_option(option_text)
380-
for option_text in pytestconfig.getoption("disks"))
387+
for option_text in disks)
381388

382389
def _host_disks(host: Host, hosts_cli_disks: list[DiskDevName] | None) -> Iterable[Host.BlockDeviceInfo]:
383390
"""Filter host disks according to list from `--cli` if given."""
@@ -721,6 +728,7 @@ def additional_repos(request: pytest.FixtureRequest, hosts: list[Host]) -> Gener
721728
@pytest.fixture(scope='session')
722729
def second_network(pytestconfig: pytest.Config, host: Host) -> str:
723730
network_uuids = pytestconfig.getoption("second_network")
731+
assert network_uuids is not None
724732
if len(network_uuids) != 1:
725733
pytest.fail("This test requires exactly one --second-network parameter!")
726734
network_uuid = network_uuids[0]

0 commit comments

Comments
 (0)