vmware / pyvmomi

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

Type stubs are not compatible with Python type checkers like mypy #1048

Open intgr opened 1 year ago

intgr commented 1 year ago

Is your feature request related to a problem? Please describe.

The type coverage of modules in pyVmomi is now pretty good, but pyVim modules are still missing type stubs. FWIW both packages are part of this repository and shipped wth the pyvmomi PyPI package.

Right now mypy prints following errors when I use it:

error: Skipping analyzing "pyVim.connect": module is installed, but missing library stubs or py.typed marker [import-untyped] error: Skipping analyzing "pyVim.task": module is installed, but missing library stubs or py.typed marker [import-untyped]

Describe the solution you'd like

Please add type hints and py.typed marker file.

Describe alternatives you've considered

No response

Additional context

No response

karaatanassov commented 9 months ago

There seem to be a number of issues with type validation in Python say with mypy. Optional[] does not seem to be use at all in declarations as noted in https://github.com/vmware/pyvmomi/issues/1056

I am changing the subject and will close related issues as duplicates of this one.

Type stubs need to be compatible with Python type checkers.