Add ContextTempOverride as context manager, support __enter__/__exit__ dunders

- Discover ContextTempOverride by probing Context.temp_override() return value
- Add __enter__ and __exit__ to _USEFUL_DUNDERS set
- Fix __enter__ return type to Self, __exit__ params to standard CM signature
- Add Self import to bpy.types generator when used in type annotations
- Remove ContextTempOverride from undefined type map (now a real class)

Remaining conformance issue: context.copy() returns dict[str, object] which
loses specific types when unpacked with **kwargs into temp_override params.
This is an inherent limitation of the copy() -> dict pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-31 12:47:44 +02:00
co-authored by Claude Opus 4.6
parent a30e772cf8
commit 80d5311e33
2 changed files with 40 additions and 3 deletions
+2
View File
@@ -553,6 +553,8 @@ def generate_types_stub(
typing_imports = ["Generic", "TypeVar"]
if "Literal[" in all_type_strs:
typing_imports.append("Literal")
if re.search(r"\bSelf\b", all_type_strs):
typing_imports.append("Self")
abc_imports = ["Iterator"]
if "Callable" in all_type_strs: