mypy: Fix implicit optional usage
Current versions of mypy run with no-implicit-optional by default. This change gets Nova's mypy test environment to pass again. Change-Id: Ie50c8d364ad9c339355cc138b560ec4df14fe307
This commit is contained in:
parent
402b155043
commit
29de62bf3b
|
@ -168,7 +168,7 @@ def _get_alias_from_config() -> Alias:
|
|||
|
||||
|
||||
def _translate_alias_to_requests(
|
||||
alias_spec: str, affinity_policy: str = None,
|
||||
alias_spec: str, affinity_policy: ty.Optional[str] = None,
|
||||
) -> ty.List['objects.InstancePCIRequest']:
|
||||
"""Generate complete pci requests from pci aliases in extra_spec."""
|
||||
pci_aliases = _get_alias_from_config()
|
||||
|
@ -255,7 +255,7 @@ def get_instance_pci_request_from_vif(
|
|||
|
||||
|
||||
def get_pci_requests_from_flavor(
|
||||
flavor: 'objects.Flavor', affinity_policy: str = None,
|
||||
flavor: 'objects.Flavor', affinity_policy: ty.Optional[str] = None,
|
||||
) -> 'objects.InstancePCIRequests':
|
||||
"""Validate and return PCI requests.
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ class PciDeviceStats(object):
|
|||
self,
|
||||
numa_topology: 'objects.NUMATopology',
|
||||
stats: 'objects.PCIDevicePoolList' = None,
|
||||
dev_filter: whitelist.Whitelist = None,
|
||||
dev_filter: ty.Optional[whitelist.Whitelist] = None,
|
||||
) -> None:
|
||||
self.numa_topology = numa_topology
|
||||
self.pools = (
|
||||
|
|
|
@ -33,7 +33,7 @@ class Whitelist(object):
|
|||
assignable.
|
||||
"""
|
||||
|
||||
def __init__(self, whitelist_spec: str = None) -> None:
|
||||
def __init__(self, whitelist_spec: ty.Optional[str] = None) -> None:
|
||||
"""White list constructor
|
||||
|
||||
For example, the following json string specifies that devices whose
|
||||
|
|
|
@ -1047,7 +1047,7 @@ class SchedulerReportClient(object):
|
|||
context: nova_context.RequestContext,
|
||||
rp_uuid: str,
|
||||
traits: ty.Iterable[str],
|
||||
generation: int = None
|
||||
generation: ty.Optional[int] = None
|
||||
):
|
||||
"""Replace a provider's traits with those specified.
|
||||
|
||||
|
|
|
@ -7636,7 +7636,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
instance: 'objects.Instance',
|
||||
power_on: bool = True,
|
||||
pause: bool = False,
|
||||
post_xml_callback: ty.Callable = None,
|
||||
post_xml_callback: ty.Optional[ty.Callable] = None,
|
||||
) -> libvirt_guest.Guest:
|
||||
"""Create a Guest from XML.
|
||||
|
||||
|
@ -7697,7 +7697,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
block_device_info: ty.Optional[ty.Dict[str, ty.Any]],
|
||||
power_on: bool = True,
|
||||
vifs_already_plugged: bool = False,
|
||||
post_xml_callback: ty.Callable = None,
|
||||
post_xml_callback: ty.Optional[ty.Callable] = None,
|
||||
external_events: ty.Optional[ty.List[ty.Tuple[str, str]]] = None,
|
||||
cleanup_instance_dir: bool = False,
|
||||
cleanup_instance_disks: bool = False,
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import typing as ty
|
||||
|
||||
from nova.virt import event
|
||||
|
||||
|
||||
|
@ -22,7 +24,10 @@ class LibvirtEvent(event.InstanceEvent):
|
|||
class DeviceEvent(LibvirtEvent):
|
||||
"""Base class for device related libvirt events"""
|
||||
|
||||
def __init__(self, uuid: str, dev: str, timestamp: float = None):
|
||||
def __init__(self,
|
||||
uuid: str,
|
||||
dev: str,
|
||||
timestamp: ty.Optional[float] = None):
|
||||
super().__init__(uuid, timestamp)
|
||||
self.dev = dev
|
||||
|
||||
|
|
|
@ -261,8 +261,8 @@ def copy_image(
|
|||
dest: str,
|
||||
host: ty.Optional[str] = None,
|
||||
receive: bool = False,
|
||||
on_execute: ty.Callable = None,
|
||||
on_completion: ty.Callable = None,
|
||||
on_execute: ty.Optional[ty.Callable] = None,
|
||||
on_completion: ty.Optional[ty.Callable] = None,
|
||||
compression: bool = True,
|
||||
) -> None:
|
||||
"""Copy a disk image to an existing directory
|
||||
|
@ -639,7 +639,7 @@ def mdev_name2uuid(mdev_name: str) -> str:
|
|||
return str(uuid.UUID(mdev_uuid))
|
||||
|
||||
|
||||
def mdev_uuid2name(mdev_uuid: str, parent: str = None) -> str:
|
||||
def mdev_uuid2name(mdev_uuid: str, parent: ty.Optional[str] = None) -> str:
|
||||
"""Convert an mdev uuid (of the form 8-4-4-4-12) and optionally its parent
|
||||
device to a name (of the form mdev_<uuid_with_underscores>[_<pciid>]).
|
||||
|
||||
|
|
Loading…
Reference in New Issue