Add rna_type/bl_rna, GeometrySet, bpy.ops typing, publish task, and README updates
- Add rna_type and bl_rna as readonly properties on bpy_struct (fixes fake-bpy-module#419) - Discover non-RNA C classes in bpy.types like GeometrySet (fixes fake-bpy-module#436) - Introspect bpy.ops operator wrapper with poll(), idname(), get_rna_type(), bl_options - Handle builtin name shadowing (e.g. bpy.ops.object) with builtins. qualification - Add poe publish task for building and publishing to PyPI - Update project URLs to Gitea, improve generated README, add disclaimer - Fix f-string lint warning and type annotation for introspect_class Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -717,6 +717,21 @@ def generate_module_stub(
|
||||
class_names = {s["name"] for s in module_data.get("structs", [])}
|
||||
result = strip_self_module_prefix(result, module_name, class_names)
|
||||
|
||||
# If any variable/class name shadows a Python builtin used as a type
|
||||
# annotation (e.g. bpy.ops has a variable named "object"), qualify it.
|
||||
_BUILTINS_USED_AS_TYPES = {"object", "type", "int", "str", "float", "bool", "set"}
|
||||
var_names = {v["name"] for v in module_data.get("variables", [])}
|
||||
shadowed = var_names & _BUILTINS_USED_AS_TYPES
|
||||
if shadowed:
|
||||
for name in shadowed:
|
||||
result = re.sub(
|
||||
rf"(?<=: ){name}\b",
|
||||
f"builtins.{name}",
|
||||
result,
|
||||
)
|
||||
if "import builtins" not in result:
|
||||
result = "import builtins\n" + result
|
||||
|
||||
# Qualify type names that clash with class names in the same module
|
||||
for clash in clashing_imports:
|
||||
match = re.search(r"from ([\w.]+) import (\w+)", clash)
|
||||
|
||||
Reference in New Issue
Block a user