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:
parent
40b2742b91
commit
9484e364c2
@ -33,8 +33,9 @@ Install alongside your Blender addon project for type checking with mypy, pyrigh
|
|||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
# Full autocomplete and type checking
|
# Full autocomplete and type checking
|
||||||
obj: bpy.types.Object = bpy.context.active_object
|
obj = bpy.context.active_object
|
||||||
obj.location.x = 1.0
|
if obj is not None:
|
||||||
|
print(obj.name)
|
||||||
|
|
||||||
# Collection types with proper methods
|
# Collection types with proper methods
|
||||||
bpy.data.objects.new("Cube", bpy.data.meshes.new("Mesh"))
|
bpy.data.objects.new("Cube", bpy.data.meshes.new("Mesh"))
|
||||||
|
|||||||
5
main.py
5
main.py
@ -185,8 +185,9 @@ pip install "blender-python-stubs>={major_minor},<{next_minor}"
|
|||||||
```python
|
```python
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
obj: bpy.types.Object = bpy.context.active_object
|
obj = bpy.context.active_object
|
||||||
obj.location.x = 1.0
|
if obj is not None:
|
||||||
|
print(obj.name)
|
||||||
|
|
||||||
bpy.data.objects.new("Cube", bpy.data.meshes.new("Mesh"))
|
bpy.data.objects.new("Cube", bpy.data.meshes.new("Mesh"))
|
||||||
```
|
```
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user