Skip to content

pyvmomi.vmodl: ManagedObjectNotFound should be derived from Exception #8082

@sodul

Description

@sodul

Mypy is raising errors where we use vmodl.fault.ManagedObjectNotFound where an Exception instance is expected.

Python 3.10.5
mypy==0.961
pyvmomi==7.0.3
types-pyvmomi==7.0.7

I tested in the repl and the instances are inheriting from Exception at runtime:

>>> isinstance(vmodl.fault.ManagedObjectNotFound(), Exception)
True

The pyi file is declaring it as a plain object which is false:

class InvalidArgument(Exception): ...

class ManagedObjectNotFound:
    obj: ManagedObject

It should be updated with the correct inheritance:

>>> vmodl.fault.ManagedObjectNotFound.__bases__
(<class 'pyVmomi.VmomiSupport.vmodl.RuntimeFault'>,)

>>> vmodl.RuntimeFault
<class 'pyVmomi.VmomiSupport.vmodl.RuntimeFault'>

>>> vmodl.RuntimeFault.__bases__
(<class 'pyVmomi.VmomiSupport.vmodl.MethodFault'>,)

>>> vmodl.MethodFault.__bases__
(<class 'pyVmomi.VmomiSupport.vmodl.DynamicData'>, <class 'Exception'>)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions