Fix typecheck errors across all Blender versions
- Strip single backtick RST markup from type annotations (` int ` -> int) - Convert "string in ['X', 'Y']" docstring patterns to Literal types - Map undefined ContextTempOverride type to object - Add Callable import to bpy.types stub generator - Fix Callable[[object, ...], X] -> Callable[..., X] for varargs - Fix Literal[...] = False incompatible defaults to use ... - Include classmethod-wrapped C builtins in RNA type C-method scan Remaining pre-existing errors: - 4.0-4.3: Sequence name clash with bpy.types.Sequence - 4.0: Node.type structural RNA conflict - 5.1: BMElemSeq/BMLayerCollection not declared as generic Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+8
-2
@@ -176,10 +176,14 @@ def format_param(param: ParamData, force_type: bool = False) -> str:
|
||||
parts.append(f": {type_str}")
|
||||
|
||||
if param["default"] is not None:
|
||||
default = param["default"]
|
||||
# Fix incompatible defaults: Literal types can't have bool defaults
|
||||
if type_str and "Literal[" in type_str and default in ("False", "True"):
|
||||
default = "..."
|
||||
if type_str:
|
||||
parts.append(f" = {param['default']}")
|
||||
parts.append(f" = {default}")
|
||||
else:
|
||||
parts.append(f"={param['default']}")
|
||||
parts.append(f"={default}")
|
||||
|
||||
return "".join(parts)
|
||||
|
||||
@@ -552,6 +556,8 @@ def generate_types_stub(
|
||||
typing_imports.append("Literal")
|
||||
|
||||
abc_imports = ["Iterator"]
|
||||
if "Callable" in all_type_strs:
|
||||
abc_imports.append("Callable")
|
||||
if "MutableSequence[" in all_type_strs:
|
||||
abc_imports.append("MutableSequence")
|
||||
# Only import bare Sequence if used without collections.abc. prefix
|
||||
|
||||
Reference in New Issue
Block a user