2013-09-18, 14:42
XBMCstubs were renamed to Kodistubs!
Started to learn how to create XBMC Python addons, I came across xbmcstubs project and started using it. Then I've decided to update it with the most recent information from the latest XBMC Python docs and my personal experience.
Currently Kodistubs are generated (indirectly) from Kodi source code so they pretty much exactly re-create Kodi Python API classes and functions. Now Kodistubs also include PEP-484 type annotations that provide information about actual arguments and return values of Kodi Python API functions and methods.
What is this and why do you need it?
Kodistubs are literally Python module stubs which mimic Kodi Python API modules. They contain all (hopefully) classes, methods, functions and constants declarations with docstrings, type annotations and minimal code not to raise syntax errors and basic exceptions.
If you using some Python IDE (PyCharm, Eclipse+Pydev, Python Tools for Visual Studio, PyScripter etc.), you can add those modules to Python import paths of your current Kodi addon project, and you will get code auto-completion, code inspection (if your IDE/code editor supports it), and quick help that greatly facilitates writing addon code and reduces the number of errors.
Where to add these stub modules in my IDE?
Simply run
Also it is strongly recommended to read Kodistubs documentation: http://romanvm.github.io/Kodistubs/
If you are documenting your code with Sphinx, this URL can also be used as intersphinx reference point for Kodi Python API.
You can find the latest Kodi Python stub modules in my Github repo.
Note: I try to keep Kodistubs in sync with Kodi Python API changes but it may happen that I miss something, so any comments, corrections, and pull requests are welcomed.
Warning: those stub modules do not include any useful code so don't try to run/debug your addon directly from IDE, unless you add some debug code to them. They are meant only to help writing addon code.
However, if you want to test your code outside Kodi (e.g. do unit testing), with Kodistubs you can use some Python mock library like mock or flexmock to mimic Kodi Python functions and classes. This will help you to eliminate at least some basic errors and bugs.
Started to learn how to create XBMC Python addons, I came across xbmcstubs project and started using it. Then I've decided to update it with the most recent information from the latest XBMC Python docs and my personal experience.
Currently Kodistubs are generated (indirectly) from Kodi source code so they pretty much exactly re-create Kodi Python API classes and functions. Now Kodistubs also include PEP-484 type annotations that provide information about actual arguments and return values of Kodi Python API functions and methods.
What is this and why do you need it?
Kodistubs are literally Python module stubs which mimic Kodi Python API modules. They contain all (hopefully) classes, methods, functions and constants declarations with docstrings, type annotations and minimal code not to raise syntax errors and basic exceptions.
If you using some Python IDE (PyCharm, Eclipse+Pydev, Python Tools for Visual Studio, PyScripter etc.), you can add those modules to Python import paths of your current Kodi addon project, and you will get code auto-completion, code inspection (if your IDE/code editor supports it), and quick help that greatly facilitates writing addon code and reduces the number of errors.
Where to add these stub modules in my IDE?
Simply run
pip install Kodistubs
to install Kodistubs into your project's virtual environment.Also it is strongly recommended to read Kodistubs documentation: http://romanvm.github.io/Kodistubs/
If you are documenting your code with Sphinx, this URL can also be used as intersphinx reference point for Kodi Python API.
You can find the latest Kodi Python stub modules in my Github repo.
Note: I try to keep Kodistubs in sync with Kodi Python API changes but it may happen that I miss something, so any comments, corrections, and pull requests are welcomed.
Warning: those stub modules do not include any useful code so don't try to run/debug your addon directly from IDE, unless you add some debug code to them. They are meant only to help writing addon code.
However, if you want to test your code outside Kodi (e.g. do unit testing), with Kodistubs you can use some Python mock library like mock or flexmock to mimic Kodi Python functions and classes. This will help you to eliminate at least some basic errors and bugs.