vmware / pyvmomi

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

Type warnings #1026

Closed IvarVirusiim closed 1 year ago

IvarVirusiim commented 1 year ago

Describe the bug

When using PyCharm and type hinting, there are warnings like those:

image

image

image

Reproduction steps

  1. Add a type hint using full path, for example: vim.vm.device.VirtualEthernetCard
  2. Look at warning that says: Cannot find reference 'vm' in '__init__.pyi': image

Expected behavior

No warnings

Additional context

For this example (vim.vm.device.VirtualEthernetCard) using re-exports should fix them:

https://typing.readthedocs.io/en/latest/source/stubs.html#imports

For example vim.__init__.pyi : from . import vim as vim

and in vm.__init__.pyi: from . import device as device

DanielDraganov commented 1 year ago

Thanks for reporting this. There is discrepancy between PyCharm and Visual Studio Code because the latter did not have issues with the imports and did not show warnings. Nevertheless, the imports are modified to comply with the "from Y import X as X" rule.

nofacer commented 11 months ago

Hi @DanielDraganov , I think this issue still exists with pyvmomi==8.0.2.0. image image