vmware / pyvmomi

VMware vSphere API Python Bindings
Apache License 2.0
2.21k stars 764 forks source link

pyvmomi==8.0.3.0.1 errors with mypy #1080

Open sodul opened 3 months ago

sodul commented 3 months ago

Describe the bug

Run mypy on code using pyvmomi, mypy will throw an error:

AssertionError: Cannot find component 'ByTime' for 'pyVmomi.vim.event.EventFilterSpec.ByTime'

Reproduction steps

pip install pyvmomi==8.0.3.0.1 types-pyvmomi==8.0.0.6 mypy==1.10.1

Call mypy on code using pyvmomi: mypy

To fix: pip install pyvmomi==8.0.2.0.1

Expected behavior

No errors.

Additional context

Relates to #862 and #1048.

phagara commented 3 months ago

another incorrect typing stub:

$ cat foo.py
from pyVmomi import vim
print(vim.TaskInfo.State.success)

$ python3 foo.py
success

$ mypy foo.py
foo.py:2: error: Module has no attribute "State"  [attr-defined]
    print(vim.TaskInfo.State.success)
          ^~~~~~~~~~~~~~~~~~
Found 1 error in 1 file (checked 1 source file)
IvarVirusiim commented 1 month ago

Some more issues:

vm: vim.VirtualMachine
vm.runtime.powerState

error: RuntimeInfo? has no attribute "powerState"  

Something relating to ManagedEntity, because many objects get error for accessing name:

Datastore? has no attribute "name" 
Network? has no attribute "name" 
ManagedEntity? has no attribute "name" 

More examples:

TaskInfo? has no attribute "state" 
TaskInfo? has no attribute "result"
DatastoreBrowser? has no attribute "SearchDatastore_Task"  
VirtualDevice? has no attribute "connectable" 
VirtualDevice? has no attribute "uptCompatibilityEnabled" 
VirtualDevice? has no attribute "backing" 
VirtualHardware? has no attribute "device"

There seems to be an issue with the underlying generation issue. Those are some of the few examples.