mirror of
https://github.com/divkit/divkit.git
synced 2026-05-07 20:02:32 +00:00
pydivkit: allow expressions in div-collection-item-builder data
commit_hash:d0a816f90d27ee7814e22e975a46fbeb5ba7a798
This commit is contained in:
@@ -269,6 +269,8 @@ class PythonPropertyType(PropertyType):
|
||||
return True
|
||||
if isinstance(self, (Color, String, Url)):
|
||||
return True
|
||||
if isinstance(self, (PythonRawArray,)):
|
||||
return True
|
||||
if isinstance(self, Object):
|
||||
if isinstance(self.object, StringEnumeration):
|
||||
return True
|
||||
|
||||
@@ -11,7 +11,7 @@ class EntityWithRawArray(BaseDiv):
|
||||
def __init__(
|
||||
self, *,
|
||||
type: str = 'entity_with_raw_array',
|
||||
array: typing.Optional[typing.Sequence[typing.Any]] = None,
|
||||
array: typing.Optional[typing.Union[Expr, typing.Sequence[typing.Any]]] = None,
|
||||
**kwargs: typing.Any,
|
||||
):
|
||||
super().__init__(
|
||||
@@ -21,7 +21,7 @@ class EntityWithRawArray(BaseDiv):
|
||||
)
|
||||
|
||||
type: str = Field(default='entity_with_raw_array')
|
||||
array: typing.Sequence[typing.Any] = Field(
|
||||
array: typing.Union[Expr, typing.Sequence[typing.Any]] = Field(
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -187,6 +187,7 @@ BUILTIN_TYPES_TO_SCHEMA: Mapping[type, Mapping[str, Any]] = MappingProxyType(
|
||||
str: MappingProxyType({"type": "string"}),
|
||||
bytes: MappingProxyType({"type": "string"}),
|
||||
Expr: MappingProxyType({"type": "string", "pattern": "^@{.*}$"}),
|
||||
Any: MappingProxyType({}),
|
||||
},
|
||||
)
|
||||
|
||||
@@ -271,7 +272,7 @@ def _field_to_schema(
|
||||
elif issubclass(type_, enum.Enum):
|
||||
schema = _enum_to_schema(type_)
|
||||
|
||||
if not schema:
|
||||
if schema is None:
|
||||
raise TypeError(f"Schema building error for unknown type {type_}")
|
||||
|
||||
if field:
|
||||
|
||||
Reference in New Issue
Block a user