File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 1616"""Provide a collection of styles."""
1717
1818
19- from typing import Iterable , List , Optional , Union
19+ from typing import Iterable , List , Union
20+
21+ from pydantic import Field
2022
2123from ..abstract_base import AbstractBase
2224from ..base_model import BaseModel
@@ -35,8 +37,8 @@ class StylesIO(BaseModel):
3537
3638 """
3739
38- elements : Optional [ List [ElementStyleIO ]]
39- relationships : Optional [ List [RelationshipStyleIO ]]
40+ elements : List [ElementStyleIO ] = Field ( default = ())
41+ relationships : List [RelationshipStyleIO ] = Field ( default = ())
4042
4143
4244class Styles (AbstractBase ):
@@ -85,3 +87,11 @@ def add_relationship_style(self, **kwargs) -> None:
8587 def clear_relationships_styles (self ) -> None :
8688 """"""
8789 self .relationships .clear ()
90+
91+ @classmethod
92+ def hydrate (cls , styles_io : StylesIO ) -> "Styles" :
93+ """"""
94+ return cls (
95+ elements = map (ElementStyle .hydrate , styles_io .elements ),
96+ relationships = map (RelationshipStyle .hydrate , styles_io .relationships ),
97+ )
You can’t perform that action at this time.
0 commit comments