From 9484e364c29e11f30f928b4a5cea9bc621ba9adb Mon Sep 17 00:00:00 2001 From: Joseph HENRY Date: Tue, 31 Mar 2026 17:17:14 +0200 Subject: [PATCH] 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) --- README.md | 5 +++-- main.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1a208c6..f177db0 100644 --- a/README.md +++ b/README.md @@ -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")) diff --git a/main.py b/main.py index 5d539dd..e8ac04c 100644 --- a/main.py +++ b/main.py @@ -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")) ```