Fix all typecheck errors across all 8 Blender versions (4.0-5.1)

- Fix Sequence name clash in bpy.types by never importing it directly
- Qualify all bare Sequence[ to collections.abc.Sequence[ in bpy.types
- Force writable properties to readonly when overriding parent @property
- Auto-detect classes used as generics and add Generic[_T] base
- Include struct bases in type string collection for import detection
- Strip RST backslash-space before generic brackets in docstrings
- Convert "string in ['X', 'Y']" docstring pattern to Literal types
- Strip single backtick RST markup from type annotations
- Fix Callable[[object, ...], X] -> Callable[..., X]
- Add Callable import to bpy.types generator
- Map ContextTempOverride to object, handle BMVertSkin removal in 5.1
- Fix Literal[...] = False incompatible defaults
- Update test for collect_inherited_info rename

Result: 0 errors on all versions (4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 5.0, 5.1)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-27 12:41:38 +01:00
co-authored by Claude Opus 4.6
parent 6ecd996f35
commit 441631d69a
3 changed files with 83 additions and 25 deletions
+8 -2
View File
@@ -320,6 +320,8 @@ def clean_type_str(type_str: str) -> str:
type_str = re.sub(r",?\s*\(readonly\)", "", type_str)
type_str = re.sub(r",?\s*\(never None\)", "", type_str)
type_str = re.sub(r":class:`([^`]+)`", r"\1", type_str)
# Strip RST escaped backslash + space before generic brackets (e.g. "Foo\ [Bar]" -> "Foo[Bar]")
type_str = re.sub("\\\\\\s*\\[", "[", type_str)
# Remove double backtick RST markup
type_str = re.sub(r"``([^`]+)``", r"\1", type_str)
# Remove single backtick markup (` int ` → int)
@@ -702,8 +704,12 @@ def clean_type_str(type_str: str) -> str:
_UNDEFINED_TYPE_MAP = {
"ContextTempOverride": "object",
}
if type_str in _UNDEFINED_TYPE_MAP:
return _UNDEFINED_TYPE_MAP[type_str]
for undef_name, replacement in _UNDEFINED_TYPE_MAP.items():
type_str = re.sub(rf"\b{undef_name}\b", replacement, type_str)
# Replace undefined types in generic arguments with object
_UNDEFINED_TYPES = {"BMVertSkin"}
for undef in _UNDEFINED_TYPES:
type_str = re.sub(rf"(?:\w+\.)*{undef}", "object", type_str)
# Final balance check — catch any remaining malformed types
if type_str.count("[") != type_str.count("]") or type_str.count(