Add more examples with typing extensions

This commit is contained in:
Xury Greer
2026-08-09 11:22:47 -07:00
parent 8caedd0973
commit e27c37318f
5 changed files with 321 additions and 1 deletions

View File

@@ -1,4 +1,9 @@
"""First party stubs for extra Blender type hints."""
"""First party stubs for extra Blender type hints.
Extends Blender's types with custom attributes that are added by this add-on.
"""
# Built-in.
from collections.abc import Iterable
# Third Party.
from bpy.types import AddonPreferences as _AddonPreferences
@@ -16,8 +21,14 @@ from bpy.types import Operator as _Operator
from bpy.types import Panel as _Panel
from bpy.types import PropertyGroup as _PropertyGroup
from bpy.types import RenderEngine as _RenderEngine
from bpy.types import Scene as _Scene
from bpy.types import UIList as _UIList
# First Party.
from ..src.blender_extension_template.props import (
EXTENSION_EXAMPLE_SettingsProperties as _EXTENSION_EXAMPLE_SettingsProperties,
)
# Classes that can be registered/unregistered.
type RegisterableTypes = type[
_Panel
@@ -37,3 +48,24 @@ type RegisterableTypes = type[
| _Gizmo
| _GizmoGroup
]
# Callback return type for EnumPropertyItems.
type ItemsCallback = Iterable[
# identifier, name, description
tuple[str, str, str]
# identifier, name, description, value
| tuple[str, str, str, int]
# identifier, name, description, icon, value
| tuple[str, str, str, str, int]
| None
]
# Override SettingsProperties to use Python native types.
class EXTENSION_EXAMPLE_SettingsProperties(_EXTENSION_EXAMPLE_SettingsProperties):
name: str
file_format: str
color_depth: str
# Override Scene type to include custom settings.
class Scene(_Scene):
example_settings: EXTENSION_EXAMPLE_SettingsProperties