Skip to content

Incorrect Type Hints on VM Operations #1099

@EnigmaticCypher

Description

@EnigmaticCypher

Describe the bug

In certain type stubs, the recent changes in 8.0.3.0.0 have resulted in the return type hint of NoReturn being used on certain operations such as VM RebootGuest(). This can be seen here: https://github.com/vmware/pyvmomi/blob/master/pyVmomi/vim/VirtualMachine.pyi#L216

This is problematic because NoReturn does not mean what the author thought it means. The NoReturn type hint means that function cannot return without raising an exception. But RebootGuest() and other functions like it in pyvmomi simply return nothing, which should be represented by a return type hint of -> None instead of -> NoReturn.

This causes erroneous warnings in IDEs about code underneath calls to functions like RebootGuest() being unreachable because the IDE expects that RebootGuest will always throw an exception (since the type hint is NoReturn) or otherwise cannot return.

Can the usage of NoReturn in the auto generated type stubs please be reviewed and updated with the proper hint.

Reproduction steps

  1. Write code to reboot VM using VirtualMachine.RebootGuest() and print "VM reboot initiated" after calling RebootGuest().
  2. Observe errors in IDE indicating that the print statement cannot be reached.

...

Expected behavior

Misleading warnings in IDEs are not present.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions