Type stubs for OpenImageIO Python bindings!
This package provides type stubs for oiio-python, enabling static type checking and better IDE support for OpenImageIO and OpenColorIO Python bindings.
- π― Complete Type Coverage: Type hints for OpenImageIO and PyOpenColorIO modules
- π IDE Support: Enhanced code completion and type checking
- β¨ MyPy Compatible: Full support for static type checking
- π Version Matched: Stubs versions match
oiio-python
releases
pip install types-oiio-python
It is recommended to add this package to your project development dependencies.
Once installed, MyPy and your most IDEs will automatically use these stubs for type checking and code completion.
Autocomplete | Type Checking |
---|---|
![]() |
![]() |
(Example in VS Code) | (Example in VS Code) |
Unfortunately Pylint does not (yet) support the use of stubs int the .pyi format.
If you use Pylint, you will need to add the following to your .pylintrc
file:
extension-pkg-whitelist=OpenImageIO,PyOpenColorIO
To avoid getting E1101:no-member
errors when using compiled modules.
The version numbers match the corresponding oiio-python releases. For example:
- types-oiio-python 2.5.12.0.x corresponds to oiio-python 2.5.12.0.x
- The stubs are generated using mypy's stubgen tool.
- Included
generate_stubs.py
script is used to generate stubs for OpenImageIO and OpenColorIO modules. - Manual adjustments are made to improve the generated stubs.
- Clone the repository
- Install in interactive mode with dev dependencies
pip install -e .[dev]
- Test the stubs with MyPy stubtest
stubtest OpenImageIO --allowlist oiio-mypy-baseline.txt stubtest PyOpenColorIO --allowlist ocio-mypy-baseline.txt