Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sodul opened this issue Jun 15, 2022 · 1 comment · Fixed by #8469
Closed

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

sodul opened this issue Jun 15, 2022 · 1 comment · Fixed by #8469

Comments

@sodul
Copy link

sodul commented Jun 15, 2022

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'>)
@JelleZijlstra
Copy link
Member

PRs are welcome!

@AlexWaygood AlexWaygood changed the title ManagedObjectNotFound should be derived from Exception. Vmodl: ManagedObjectNotFound should be derived from Exception. Jun 15, 2022
@AlexWaygood AlexWaygood changed the title Vmodl: ManagedObjectNotFound should be derived from Exception. pyvmomi.vmodl: ManagedObjectNotFound should be derived from Exception Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants