From 224a10d1d322d89e2602858ac98db2d602e0fcc1 Mon Sep 17 00:00:00 2001 From: p3rf Team Date: Mon, 12 Feb 2024 17:09:53 -0800 Subject: [PATCH] Resolve unsoundness caught by pytype --strict-none-binding. PiperOrigin-RevId: 606415588 --- perfkitbenchmarker/edw_service.py | 4 +++- .../linux_benchmarks/bidirectional_network_benchmark.py | 2 +- perfkitbenchmarker/linux_benchmarks/mpi_benchmark.py | 7 +++++-- .../linux_benchmarks/object_storage_service_benchmark.py | 2 +- .../providers/ibmcloud/ibmcloud_virtual_machine.py | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/perfkitbenchmarker/edw_service.py b/perfkitbenchmarker/edw_service.py index 3c3241695b..b568717c71 100644 --- a/perfkitbenchmarker/edw_service.py +++ b/perfkitbenchmarker/edw_service.py @@ -290,6 +290,8 @@ def ExecuteThroughput(self, concurrency_streams: List[List[str]]) -> str: def WarmUpQuery(self): """Executes a service-agnostic query that can detect cold start issues.""" + if self.client_vm is None: + raise ValueError('SetProvisionedAttributes() not called') with open(SAMPLE_QUERY_PATH, 'w+') as f: f.write(SAMPLE_QUERY) self.client_vm.PushFile(SAMPLE_QUERY_PATH) @@ -344,7 +346,7 @@ def __init__(self, edw_service_spec): self.spec = edw_service_spec # resource workflow management self.supports_wait_on_delete = True - self.client_interface = None + self.client_interface: EdwClientInterface def GetClientInterface(self) -> EdwClientInterface: """Gets the active Client Interface.""" diff --git a/perfkitbenchmarker/linux_benchmarks/bidirectional_network_benchmark.py b/perfkitbenchmarker/linux_benchmarks/bidirectional_network_benchmark.py index ee41e5b53b..daabf0822e 100644 --- a/perfkitbenchmarker/linux_benchmarks/bidirectional_network_benchmark.py +++ b/perfkitbenchmarker/linux_benchmarks/bidirectional_network_benchmark.py @@ -335,7 +335,7 @@ def Run(benchmark_spec): vms = benchmark_spec.vms num_tests = len(FLAGS.bidirectional_network_tests) num_streams = FLAGS.bidirectional_stream_num_streams - test_results = [None] * num_tests + test_results = [([], 0., 0.)] * num_tests args = [ ( diff --git a/perfkitbenchmarker/linux_benchmarks/mpi_benchmark.py b/perfkitbenchmarker/linux_benchmarks/mpi_benchmark.py index 99db2357cf..0edd72107b 100644 --- a/perfkitbenchmarker/linux_benchmarks/mpi_benchmark.py +++ b/perfkitbenchmarker/linux_benchmarks/mpi_benchmark.py @@ -5,7 +5,7 @@ """ import logging -from typing import Any, Dict, Iterator, List, Tuple +from typing import Any, Dict, Iterator, List, Tuple, TypeVar from absl import flags from perfkitbenchmarker import background_tasks from perfkitbenchmarker import benchmark_spec @@ -16,7 +16,10 @@ from perfkitbenchmarker import sample from perfkitbenchmarker.linux_packages import mpi -_BaseLinuxVirtualMachine = linux_virtual_machine.BaseLinuxVirtualMachine +_BaseLinuxVirtualMachine = TypeVar( + '_BaseLinuxVirtualMachine', + bound=linux_virtual_machine.BaseLinuxVirtualMachine, +) # documents the individual MPI tests in each suite _MPI_SUITE_TESTS = { diff --git a/perfkitbenchmarker/linux_benchmarks/object_storage_service_benchmark.py b/perfkitbenchmarker/linux_benchmarks/object_storage_service_benchmark.py index aba0be4ab5..16b8c12294 100644 --- a/perfkitbenchmarker/linux_benchmarks/object_storage_service_benchmark.py +++ b/perfkitbenchmarker/linux_benchmarks/object_storage_service_benchmark.py @@ -1112,7 +1112,7 @@ def _RunMultiStreamProcesses(vms, command_builder, cmd_args, streams_per_vm): streams_per_vm: number of threads per vm. """ - output = [None] * len(vms) + output = [''] * len(vms) def RunOneProcess(vm_idx): logging.info('Running on VM %s.', vm_idx) diff --git a/perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py b/perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py index 064dee54bf..271d0c9e95 100644 --- a/perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py +++ b/perfkitbenchmarker/providers/ibmcloud/ibmcloud_virtual_machine.py @@ -78,7 +78,7 @@ def __init__(self, vm_spec: virtual_machine.BaseVmSpec): self.zone = 'us-south-1' # default self.fip_address = None self.fip_id = None - self.network = None + self.network: ibmcloud_network.IbmCloudNetwork self.subnet = FLAGS.ibmcloud_subnet self.subnets = {} self.vpcid = FLAGS.ibmcloud_vpcid