Skip to content

Commit f3dfa78

Browse files
authored
fix(convert): ClassVar was ignored by Pydantic (#292)
* fix(convert): ClassVar was ignored by Pydantic Using default factory function instead. * update comments
1 parent 6c9505b commit f3dfa78

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

manim_slides/convert.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from enum import Enum
1010
from importlib import resources
1111
from pathlib import Path
12-
from typing import Any, Callable, ClassVar, Dict, List, Optional, Type, Union
12+
from typing import Any, Callable, Dict, List, Optional, Type, Union
1313

1414
import click
1515
import cv2
@@ -21,6 +21,7 @@
2121
from pydantic import (
2222
BaseModel,
2323
ConfigDict,
24+
Field,
2425
FilePath,
2526
GetCoreSchemaHandler,
2627
PositiveFloat,
@@ -303,20 +304,22 @@ class RevealJS(Converter):
303304
auto_animate_easing: AutoAnimateEasing = AutoAnimateEasing.ease
304305
auto_animate_duration: float = 1.0
305306
auto_animate_unmatched: JsBool = JsBool.true
306-
auto_animate_styles: ClassVar[List[str]] = [
307-
"opacity",
308-
"color",
309-
"background-color",
310-
"padding",
311-
"font-size",
312-
"line-height",
313-
"letter-spacing",
314-
"border-width",
315-
"border-color",
316-
"border-radius",
317-
"outline",
318-
"outline-offset",
319-
]
307+
auto_animate_styles: List[str] = Field(
308+
default_factory=lambda: [
309+
"opacity",
310+
"color",
311+
"background-color",
312+
"padding",
313+
"font-size",
314+
"line-height",
315+
"letter-spacing",
316+
"border-width",
317+
"border-color",
318+
"border-radius",
319+
"outline",
320+
"outline-offset",
321+
]
322+
)
320323
auto_slide: AutoSlide = 0
321324
auto_slide_stoppable: JsBool = JsBool.true
322325
auto_slide_method: Union[AutoSlideMethod, Function] = AutoSlideMethod.null
@@ -338,11 +341,12 @@ class RevealJS(Converter):
338341
display: Display = Display.block
339342
hide_inactive_cursor: JsBool = JsBool.true
340343
hide_cursor_time: int = 5000
341-
# Add. options
344+
# Appearance options from RevealJS
342345
background_color: str = "black" # TODO: use pydantic.color.Color
343346
reveal_version: str = "4.6.1"
344347
reveal_theme: RevealTheme = RevealTheme.black
345348
title: str = "Manim Slides"
349+
# Pydantic options
346350
model_config = ConfigDict(use_enum_values=True, extra="forbid")
347351

348352
def load_template(self) -> str:

0 commit comments

Comments
 (0)