PyAPI: use postponed annotations to support Python 3.10
Support Python 3.10a5 or 3.9x with support explicitly enabled. - Enable Python's postponed annotations for Blender's RNA classes types registered on startup. - Using postponed annotations has implications for how they are defined, since they must evaluate in the modules name-space instead of the classes name-space. See changes to annotations in `release/scripts`. - Use `from __future__ import annotations` at the top of the module to ensure the script will run with Python 3.10. - Old logic is kept since it could be used if PEP-649 is supported. Resolves T83626 Ref D10474
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
# ##### END GPL LICENSE BLOCK #####
|
||||
|
||||
# <pep8 compliant>
|
||||
from __future__ import annotations
|
||||
|
||||
# support reloading sub-modules
|
||||
if "bpy" in locals():
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
# ##### END GPL LICENSE BLOCK #####
|
||||
|
||||
# <pep8-80 compliant>
|
||||
from __future__ import annotations
|
||||
|
||||
import bpy
|
||||
from bpy.types import Operator
|
||||
|
||||
@@ -156,7 +158,7 @@ class AddTorus(Operator, object_utils.AddObjectHelper):
|
||||
('EXT_INT', "Exterior/Interior",
|
||||
"Use the exterior/interior radii for torus dimensions"),
|
||||
),
|
||||
update=mode_update_callback,
|
||||
update=AddTorus.mode_update_callback,
|
||||
)
|
||||
major_radius: FloatProperty(
|
||||
name="Major Radius",
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# ##### END GPL LICENSE BLOCK #####
|
||||
|
||||
# <pep8-80 compliant>
|
||||
from __future__ import annotations
|
||||
|
||||
if "bpy" in locals():
|
||||
from importlib import reload
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
#
|
||||
# ##### END GPL LICENSE BLOCK #####
|
||||
|
||||
# <pep8 compliant>
|
||||
from __future__ import annotations
|
||||
|
||||
import bpy
|
||||
|
||||
from bpy_extras.asset_utils import (
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# ##### END GPL LICENSE BLOCK #####
|
||||
|
||||
# <pep8-80 compliant>
|
||||
from __future__ import annotations
|
||||
|
||||
import bpy
|
||||
from bpy.types import Operator
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# ##### END GPL LICENSE BLOCK #####
|
||||
|
||||
# <pep8-80 compliant>
|
||||
from __future__ import annotations
|
||||
|
||||
from bpy.types import (
|
||||
Operator,
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# ##### END GPL LICENSE BLOCK #####
|
||||
|
||||
# <pep8-80 compliant>
|
||||
from __future__ import annotations
|
||||
|
||||
import bpy
|
||||
import nodeitems_utils
|
||||
@@ -218,7 +219,7 @@ class NODE_OT_add_search(NodeAddOperator, Operator):
|
||||
node_item: EnumProperty(
|
||||
name="Node Type",
|
||||
description="Node type",
|
||||
items=node_enum_items,
|
||||
items=NODE_OT_add_search.node_enum_items,
|
||||
)
|
||||
|
||||
def execute(self, context):
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# ##### END GPL LICENSE BLOCK #####
|
||||
|
||||
# <pep8 compliant>
|
||||
from __future__ import annotations
|
||||
|
||||
import bpy
|
||||
from bpy.types import (
|
||||
@@ -859,9 +860,7 @@ class WM_OT_url_open_preset(Operator):
|
||||
|
||||
type: EnumProperty(
|
||||
name="Site",
|
||||
items=lambda self, _context: (
|
||||
item for (item, _) in WM_OT_url_open_preset.preset_items
|
||||
),
|
||||
items=WM_OT_url_open_preset._preset_items,
|
||||
)
|
||||
|
||||
id: StringProperty(
|
||||
@@ -916,6 +915,10 @@ class WM_OT_url_open_preset(Operator):
|
||||
"https://www.blender.org/about/credits/"),
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def _preset_items(_self, _context):
|
||||
return (item for (item, _) in WM_OT_url_open_preset.preset_items)
|
||||
|
||||
def execute(self, context):
|
||||
url = None
|
||||
type = self.type
|
||||
|
||||
Reference in New Issue
Block a user