RNA enum properties support

This commit is contained in:
2026-09-21 11:18:10 +02:00
parent f575a84c13
commit f2efa629ba
8 changed files with 134 additions and 8 deletions
+6 -3
View File
@@ -17,6 +17,7 @@ The version matches your target Blender version:
| Blender Version | Install Command | PyPI |
| --------------- | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| 5.2 | `pip install "blender-python-stubs>=5.2,<5.3"` | [![PyPI](https://img.shields.io/badge/PyPI-5.2-blue?logo=pypi)](https://pypi.org/project/blender-python-stubs/5.2.1.1/) |
| 5.1 | `pip install "blender-python-stubs>=5.1,<5.2"` | [![PyPI](https://img.shields.io/badge/PyPI-5.1-blue?logo=pypi)](https://pypi.org/project/blender-python-stubs/5.1.0.1/) |
| 5.0 | `pip install "blender-python-stubs>=5.0,<5.1"` | [![PyPI](https://img.shields.io/badge/PyPI-5.0-blue?logo=pypi)](https://pypi.org/project/blender-python-stubs/5.0.1.0/) |
| 4.5 | `pip install "blender-python-stubs>=4.5,<4.6"` | [![PyPI](https://img.shields.io/badge/PyPI-4.5-blue?logo=pypi)](https://pypi.org/project/blender-python-stubs/4.5.8.1/) |
@@ -56,6 +57,8 @@ gpu.state.blend_set('ALPHA')
- **Context members** — `bpy.context.active_object`, `selected_objects`, `edit_object`, and ~100 other screen context attributes are properly typed
- **Constructor signatures** — GPU types, mathutils types (`Vector`, `Matrix`, `Euler`, etc.) have typed `__init__` methods
- **Literal enum types** — string parameters like `gpu.state.blend_set(mode)` use `Literal["NONE", "ALPHA", ...]` instead of plain `str`
- **RNA enum properties** — class properties such as `bpy.types.Panel.bl_space_type` derive their `Literal[...]` values directly from Blender RNA metadata
- **Reusable enum aliases** — annotate addon class attributes with `bpy.types.SpaceType` or `bpy.types.RegionType` instead of repeating every allowed literal
- **Docstrings** — inline documentation on properties, methods, and functions
- **Classmethod detection** — `Matrix.Identity()`, `Vector.Fill()`, etc. correctly typed as `@classmethod`
- **Dunder methods** — `__getitem__`, `__len__`, `__add__`, `__matmul__`, and other operators introspected with correct return types (e.g. `Matrix[0]` returns `Vector`)
@@ -101,20 +104,20 @@ bpystubgen generates stubs from Blender's Sphinx documentation, not from runtime
## Supported Versions
Blender 4.0 through 5.1. Each Blender version gets its own stub package version.
Blender 4.0 through 5.2. Each Blender version gets its own stub package version.
## Generating Stubs
To generate stubs for a specific Blender version, run:
```bash
uv run poe generate 5.1
uv run poe generate 5.2
```
This will automatically download the corresponding Blender executable and run the introspection and stub generation process. You can also type-check the generated stubs:
```bash
uv run poe typecheck-stubs 5.1
uv run poe typecheck-stubs 5.2
```
## Contributing