From 666b3767e1ce7b69996a6259f3cab841da97b14c Mon Sep 17 00:00:00 2001 From: elsholz Date: Sun, 14 Jan 2024 00:16:50 +0100 Subject: [PATCH] change color to annotated type --- api/code/metroplanner_api/type_definitions.py | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/api/code/metroplanner_api/type_definitions.py b/api/code/metroplanner_api/type_definitions.py index d440e84..9d705b8 100644 --- a/api/code/metroplanner_api/type_definitions.py +++ b/api/code/metroplanner_api/type_definitions.py @@ -42,19 +42,20 @@ class MissingValueBaseClass(BaseModel): MaybeLocalizedShortText = Union[LocalizedShortText, ShortText] MaybeLocalizedLongText = Union[LocalizedLongText, LongText] Identifier = Annotated[str, pydantic.StringConstraints(max_length=36, min_length=36)] -ColorCSS = pydantic_extra_types.color.Color -ColorReference = pydantic.constr( - pattern=( - r"(^(fore|back)ground$)" - r"|(^landscape::(((deep|shallow)?water)|border)$)" - r"|(^lines::\d{1,3}$)" - ) -) +# ColorCSS = pydantic_extra_types.color.Color +ColorCSS = Annotated[str, pydantic_extra_types.color.Color] +ColorReference = Annotated[ + str, + pydantic.StringConstraints( + pattern=( + r"(^(fore|back)ground$)" + r"|(^landscape::(((deep|shallow)?water)|border)$)" + r"|(^lines::\d{1,3}$)" + ) + ), +] Color = Union[ColorReference, ColorCSS] - -# Point = Tuple[IntOrFloat, IntOrFloat] - Point = pydantic.conlist(IntOrFloat, min_length=2, max_length=2) @@ -205,7 +206,7 @@ class CreatePlanstate( PlanstateDimensions, PlanstateComponents, # PlanstateComponentOderings - ModelMayMissFields, + ModelMayMissFields, ): color_theme: MaybeMissing(Optional[Union[str, ObjectId]]) = Missing make_current: bool = False