Add overrides to all versions and fix 4.3 temp_override hang
- Copy gpu.state, bpy.path, gpu.types overrides to 4.0-4.5 - Add bpy.msgbus override for 4.5 - Skip temp_override probe on Blender < 4.4 (hangs on 4.3) - Fix _is_getset_writable to use docstring hints instead of __set__ probe Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a6f70f776f
commit
fe6deadfc7
@ -1433,25 +1433,15 @@ def _fix_dunder_signatures(
|
||||
def _is_getset_writable(cls: type[object], attr_name: str) -> bool:
|
||||
"""Test if a C getset_descriptor property is writable.
|
||||
|
||||
C getset_descriptors that have a setter implement __set__.
|
||||
Those without a setter raise AttributeError on __set__ calls.
|
||||
We test this by checking if __set__ raises on a dummy call.
|
||||
We check the docstring for "(read-only)" or "(readonly)" hints.
|
||||
If no hint is found, assume writable (most C getset_descriptors are).
|
||||
"""
|
||||
descriptor = cls.__dict__.get(attr_name)
|
||||
if descriptor is None:
|
||||
return False
|
||||
# If the descriptor doesn't implement __set__ at all, it's read-only
|
||||
if not hasattr(descriptor, "__set__"):
|
||||
doc = getattr(descriptor, "__doc__", "") or ""
|
||||
if "read-only" in doc.lower() or "readonly" in doc.lower():
|
||||
return False
|
||||
# Try calling __set__ with None — a writable descriptor will attempt
|
||||
# the set (and fail on None), while a read-only one raises AttributeError
|
||||
try:
|
||||
descriptor.__set__(None, None)
|
||||
except AttributeError:
|
||||
return False
|
||||
except Exception:
|
||||
# Any other error means __set__ exists (it just didn't like our args)
|
||||
return True
|
||||
return True
|
||||
|
||||
|
||||
@ -2720,20 +2710,22 @@ def introspect_rna_types() -> ModuleData:
|
||||
known = {s["name"] for s in structs}
|
||||
bpy = importlib.import_module("bpy")
|
||||
ctx = getattr(bpy, "context")
|
||||
_HIDDEN_TYPE_PROBES: list[tuple[object, str]] = [
|
||||
(ctx, "temp_override"),
|
||||
]
|
||||
for obj, method_name in _HIDDEN_TYPE_PROBES:
|
||||
func = getattr(obj, method_name, None)
|
||||
if func is None or not callable(func):
|
||||
continue
|
||||
# Probe temp_override to discover ContextTempOverride.
|
||||
# Skip on Blender < 4.4 where this call hangs.
|
||||
bpy_app = importlib.import_module("bpy.app")
|
||||
blender_version: tuple[int, ...] = getattr(bpy_app, "version", (0, 0, 0))
|
||||
temp_override = ctx.__class__.__dict__.get("temp_override")
|
||||
if (
|
||||
temp_override is not None
|
||||
and type(temp_override).__name__ == "method_descriptor"
|
||||
and blender_version >= (4, 4, 0)
|
||||
):
|
||||
try:
|
||||
result = func()
|
||||
result = ctx.temp_override()
|
||||
result_cls = result.__class__
|
||||
if result_cls.__name__ not in known:
|
||||
structs.append(introspect_class(result_cls, "bpy.types"))
|
||||
known.add(result_cls.__name__)
|
||||
# Clean up context manager if applicable
|
||||
exit_fn = getattr(result, "__exit__", None)
|
||||
if exit_fn is not None:
|
||||
exit_fn(None, None, None)
|
||||
|
||||
22
overrides/4.0/bpy.path.json
Normal file
22
overrides/4.0/bpy.path.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"abspath": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
},
|
||||
"basename": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
},
|
||||
"is_subdir": {
|
||||
"params": {
|
||||
"directory": "str | bytes"
|
||||
}
|
||||
},
|
||||
"native_pathsep": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
}
|
||||
}
|
||||
8
overrides/4.0/gpu.state.json
Normal file
8
overrides/4.0/gpu.state.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"active_framebuffer_get": {
|
||||
"return_type": "gpu.types.GPUFrameBuffer"
|
||||
},
|
||||
"viewport_get": {
|
||||
"return_type": "tuple[int, int, int, int]"
|
||||
}
|
||||
}
|
||||
7
overrides/4.0/gpu.types.json
Normal file
7
overrides/4.0/gpu.types.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"GPUShader.uniform_float": {
|
||||
"params": {
|
||||
"value": "float | int | Sequence[float] | mathutils.Matrix | mathutils.Vector | mathutils.Euler | mathutils.Quaternion | mathutils.Color"
|
||||
}
|
||||
}
|
||||
}
|
||||
22
overrides/4.1/bpy.path.json
Normal file
22
overrides/4.1/bpy.path.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"abspath": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
},
|
||||
"basename": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
},
|
||||
"is_subdir": {
|
||||
"params": {
|
||||
"directory": "str | bytes"
|
||||
}
|
||||
},
|
||||
"native_pathsep": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
}
|
||||
}
|
||||
8
overrides/4.1/gpu.state.json
Normal file
8
overrides/4.1/gpu.state.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"active_framebuffer_get": {
|
||||
"return_type": "gpu.types.GPUFrameBuffer"
|
||||
},
|
||||
"viewport_get": {
|
||||
"return_type": "tuple[int, int, int, int]"
|
||||
}
|
||||
}
|
||||
7
overrides/4.1/gpu.types.json
Normal file
7
overrides/4.1/gpu.types.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"GPUShader.uniform_float": {
|
||||
"params": {
|
||||
"value": "float | int | Sequence[float] | mathutils.Matrix | mathutils.Vector | mathutils.Euler | mathutils.Quaternion | mathutils.Color"
|
||||
}
|
||||
}
|
||||
}
|
||||
22
overrides/4.2/bpy.path.json
Normal file
22
overrides/4.2/bpy.path.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"abspath": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
},
|
||||
"basename": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
},
|
||||
"is_subdir": {
|
||||
"params": {
|
||||
"directory": "str | bytes"
|
||||
}
|
||||
},
|
||||
"native_pathsep": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
}
|
||||
}
|
||||
8
overrides/4.2/gpu.state.json
Normal file
8
overrides/4.2/gpu.state.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"active_framebuffer_get": {
|
||||
"return_type": "gpu.types.GPUFrameBuffer"
|
||||
},
|
||||
"viewport_get": {
|
||||
"return_type": "tuple[int, int, int, int]"
|
||||
}
|
||||
}
|
||||
7
overrides/4.2/gpu.types.json
Normal file
7
overrides/4.2/gpu.types.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"GPUShader.uniform_float": {
|
||||
"params": {
|
||||
"value": "float | int | Sequence[float] | mathutils.Matrix | mathutils.Vector | mathutils.Euler | mathutils.Quaternion | mathutils.Color"
|
||||
}
|
||||
}
|
||||
}
|
||||
22
overrides/4.3/bpy.path.json
Normal file
22
overrides/4.3/bpy.path.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"abspath": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
},
|
||||
"basename": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
},
|
||||
"is_subdir": {
|
||||
"params": {
|
||||
"directory": "str | bytes"
|
||||
}
|
||||
},
|
||||
"native_pathsep": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
}
|
||||
}
|
||||
8
overrides/4.3/gpu.state.json
Normal file
8
overrides/4.3/gpu.state.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"active_framebuffer_get": {
|
||||
"return_type": "gpu.types.GPUFrameBuffer"
|
||||
},
|
||||
"viewport_get": {
|
||||
"return_type": "tuple[int, int, int, int]"
|
||||
}
|
||||
}
|
||||
7
overrides/4.3/gpu.types.json
Normal file
7
overrides/4.3/gpu.types.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"GPUShader.uniform_float": {
|
||||
"params": {
|
||||
"value": "float | int | Sequence[float] | mathutils.Matrix | mathutils.Vector | mathutils.Euler | mathutils.Quaternion | mathutils.Color"
|
||||
}
|
||||
}
|
||||
}
|
||||
22
overrides/4.4/bpy.path.json
Normal file
22
overrides/4.4/bpy.path.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"abspath": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
},
|
||||
"basename": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
},
|
||||
"is_subdir": {
|
||||
"params": {
|
||||
"directory": "str | bytes"
|
||||
}
|
||||
},
|
||||
"native_pathsep": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
}
|
||||
}
|
||||
8
overrides/4.4/gpu.state.json
Normal file
8
overrides/4.4/gpu.state.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"active_framebuffer_get": {
|
||||
"return_type": "gpu.types.GPUFrameBuffer"
|
||||
},
|
||||
"viewport_get": {
|
||||
"return_type": "tuple[int, int, int, int]"
|
||||
}
|
||||
}
|
||||
7
overrides/4.4/gpu.types.json
Normal file
7
overrides/4.4/gpu.types.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"GPUShader.uniform_float": {
|
||||
"params": {
|
||||
"value": "float | int | Sequence[float] | mathutils.Matrix | mathutils.Vector | mathutils.Euler | mathutils.Quaternion | mathutils.Color"
|
||||
}
|
||||
}
|
||||
}
|
||||
22
overrides/4.5/bpy.path.json
Normal file
22
overrides/4.5/bpy.path.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"abspath": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
},
|
||||
"basename": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
},
|
||||
"is_subdir": {
|
||||
"params": {
|
||||
"directory": "str | bytes"
|
||||
}
|
||||
},
|
||||
"native_pathsep": {
|
||||
"params": {
|
||||
"path": "str | bytes"
|
||||
}
|
||||
}
|
||||
}
|
||||
8
overrides/4.5/gpu.state.json
Normal file
8
overrides/4.5/gpu.state.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"active_framebuffer_get": {
|
||||
"return_type": "gpu.types.GPUFrameBuffer"
|
||||
},
|
||||
"viewport_get": {
|
||||
"return_type": "tuple[int, int, int, int]"
|
||||
}
|
||||
}
|
||||
7
overrides/4.5/gpu.types.json
Normal file
7
overrides/4.5/gpu.types.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"GPUShader.uniform_float": {
|
||||
"params": {
|
||||
"value": "float | int | Sequence[float] | mathutils.Matrix | mathutils.Vector | mathutils.Euler | mathutils.Quaternion | mathutils.Color"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user