Skip to content
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

pylint and mypy support #862

Open
sodul opened this issue Nov 15, 2019 · 6 comments
Open

pylint and mypy support #862

sodul opened this issue Nov 15, 2019 · 6 comments

Comments

@sodul
Copy link

sodul commented Nov 15, 2019

We use pylint and mypy to ensure high quality in our code, unfortunately both tools are confused about the pyvmomi package.

For example from pyVmomi import vim, vmodl throws a 'no-name-in-module' error with pylint and we have to silence it.

With mypy, and IDEs that support type annotation, we get errors such as vmodl.query.PropertyCollector? has no attribute "CreateFilter".

Are there instructions or plans on making pyvmomi work better with pylint and mypy?

@kumahesh
Copy link
Contributor

Hi @sodul ,

Refer [1], Definitions for vim and vmodl are created by the vmomi runtime on the fly. Static type checking packages won't work. The definition for the name 'vim' loaded from the bindings while run time.

[1]

for name in pyVmomi.VmomiSupport._topLevelNames:

@sodul
Copy link
Author

sodul commented Nov 21, 2019

Is it possible to use the if TYPE_CHECKING: trick to preload the top level names, and possibly all of the names so that the runtime behavior is preserved but type checkers become aware of the types. This would help boost the productivity of the pyvmomi users.

@sunaurus
Copy link

sunaurus commented Jan 9, 2020

For a complicated library like this, type hints would improve the developer experience IMMENSELY.

It seems that all the type information is already available in documentation, could you not leverage this information in your build process and automatically generate type stubs?

FYI: PEP 561 covers how to distribute type information.

@zbennett10
Copy link

zbennett10 commented Jul 17, 2020

I'm going to try and have a crack at this one... :D

@intgr
Copy link

intgr commented Jan 21, 2021

@zbennett10 Hi, did you get anywhere with your attempt?

@alexshpilkin
Copy link

There seems to have been some initial work in this direction with 81d0e9f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants