Fix README code snippet to pass type checking

active_object is Object | None, needs a None check before use.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joseph HENRY 2026-03-31 17:17:14 +02:00
parent 40b2742b91
commit 9484e364c2
2 changed files with 6 additions and 4 deletions

View File

@ -33,8 +33,9 @@ Install alongside your Blender addon project for type checking with mypy, pyrigh
import bpy
# Full autocomplete and type checking
obj: bpy.types.Object = bpy.context.active_object
obj.location.x = 1.0
obj = bpy.context.active_object
if obj is not None:
print(obj.name)
# Collection types with proper methods
bpy.data.objects.new("Cube", bpy.data.meshes.new("Mesh"))

View File

@ -185,8 +185,9 @@ pip install "blender-python-stubs>={major_minor},<{next_minor}"
```python
import bpy
obj: bpy.types.Object = bpy.context.active_object
obj.location.x = 1.0
obj = bpy.context.active_object
if obj is not None:
print(obj.name)
bpy.data.objects.new("Cube", bpy.data.meshes.new("Mesh"))
```