RNA enum properties support
This commit is contained in:
@@ -21,6 +21,7 @@ from introspect import (
|
||||
parse_docstring_types,
|
||||
python_type_name,
|
||||
rna_property_to_type,
|
||||
rna_enum_literal_type,
|
||||
)
|
||||
|
||||
|
||||
@@ -254,6 +255,31 @@ class TestParseDocstringTypes(unittest.TestCase):
|
||||
self.assertEqual(clean_type_str("SettingsGroup"), "SettingsGroup")
|
||||
|
||||
|
||||
class TestRnaEnumLiteralType(unittest.TestCase):
|
||||
def test_reads_enum_identifiers_from_rna_metadata(self) -> None:
|
||||
enum_property = SimpleNamespace(
|
||||
type="ENUM",
|
||||
enum_items=[
|
||||
SimpleNamespace(identifier="EMPTY"),
|
||||
SimpleNamespace(identifier="VIEW_3D"),
|
||||
],
|
||||
)
|
||||
rna = SimpleNamespace(properties={"bl_space_type": enum_property})
|
||||
cls = cast(type[object], SimpleNamespace(bl_rna=rna))
|
||||
|
||||
self.assertEqual(
|
||||
rna_enum_literal_type(cls, "bl_space_type"),
|
||||
'Literal["EMPTY", "VIEW_3D"]',
|
||||
)
|
||||
|
||||
def test_returns_none_for_non_enum_properties(self) -> None:
|
||||
prop = SimpleNamespace(type="STRING")
|
||||
rna = SimpleNamespace(properties={"name": prop})
|
||||
cls = cast(type[object], SimpleNamespace(bl_rna=rna))
|
||||
|
||||
self.assertIsNone(rna_enum_literal_type(cls, "name"))
|
||||
|
||||
|
||||
class TestRefineTypesByContext(unittest.TestCase):
|
||||
def test_bool_vector_default(self) -> None:
|
||||
param_types = {"default": "Sequence"}
|
||||
|
||||
Reference in New Issue
Block a user