Python interface definition stubs / modules (.pyi files) are a standardized way to describe API that is accessible from Python, but not implemented as Python code. They can contain type information which advanced Python editors like Visual Studio Code with the Python extension can utilize to provide very smart auto-completion and static type checking.
I have produced / generated full pyi definition for VC 4.8 Premium’s API based on the new online help.
Here is a (silent) demo of using these with Visual Studio Code, using Pylance as type checker.
- Includes all Python classes and their members (properties, methods, constructors, events) + constants as described in the online help.
- Includes accurate type information where possible.
- Includes descriptions and direct links to the online help.
- Module organization is similar to VC. Functions from vcScript, vcCommand, vcVector etc. can be imported.
- Definitions for some base classes such as vcBehaviour have to include properties that may only exist in some of the behaviours. These have a note in the description.
- Type checkers don’t really support Python 2 anymore, so they will complain about print statements and assignments between types because casts can’t be used.
- Dynamically created properties can’t be known so they are not included.
How to use with Visual Studio Code
- Download and extract the pyi files to some convenient location.
- Install VS Code, the Python extension and Pylance extension.
- Add the pyi module folder to “python.autoComplete.extraPaths” and “python.analysis.extraPaths” settings of the Python extension.
- Configure VC to use VS code as external Python editor.
- Open Python scripts from VC, configure VS Code to trust the folder path to enable all editor features.
- Enable type checking in VS code.
vcApi VC48.zip (146.6 KB)