@@ -78,6 +78,18 @@ def mapping_sub_block(
7878 return val
7979
8080
81+ def require_yaml_string (value : Any , * , label : str , source : str ) -> str :
82+ """Require a YAML string so unquoted ``01`` is not silently coerced to ``\" 1\" ``."""
83+ if isinstance (value , str ):
84+ if not value .strip ():
85+ raise ConfigError (f"{ source } : { label } must be a non-empty string" )
86+ return value
87+ raise ConfigError (
88+ f"{ source } : { label } must be a YAML string, not { type (value ).__name__ } "
89+ f"({ value !r} ). Unquoted 01 is integer 1; write \" 01\" ."
90+ )
91+
92+
8193def string_list_block (
8294 raw : dict [str , Any ],
8395 key : str ,
@@ -95,7 +107,10 @@ def string_list_block(
95107 raise ConfigError (
96108 f"{ source } : { name } must be a YAML list, not { type (val ).__name__ } "
97109 )
98- return [str (x ) for x in val ]
110+ return [
111+ require_yaml_string (x , label = f"{ name } [{ i } ]" , source = source )
112+ for i , x in enumerate (val )
113+ ]
99114
100115
101116@dataclass
@@ -155,21 +170,31 @@ def __post_init__(self) -> None:
155170 _ = self .segments_all
156171 _ = self .manim_scenes
157172 concat = self ._block ("concat" )
173+ src = self ._source_label ()
158174 for name , segs in concat .items ():
159175 if segs is None :
160176 continue
161177 if not isinstance (segs , list ):
162178 raise ConfigError (
163- f"{ self . _source_label () } : concat.{ name } must be a YAML list, "
179+ f"{ src } : concat.{ name } must be a YAML list, "
164180 f"not { type (segs ).__name__ } "
165181 )
182+ for i , item in enumerate (segs ):
183+ require_yaml_string (item , label = f"concat.{ name } [{ i } ]" , source = src )
184+ for key in self ._block ("segment_names" ):
185+ require_yaml_string (key , label = "segment_names key" , source = src )
186+ pages_segs = self ._block ("pages" ).get ("segments" )
187+ if isinstance (pages_segs , dict ):
188+ for key in pages_segs :
189+ require_yaml_string (key , label = "pages.segments key" , source = src )
166190 vm = self ._block ("visual_map" )
167191 for sid , spec in vm .items ():
192+ sid_s = require_yaml_string (sid , label = "visual_map key" , source = src )
168193 if spec is None :
169194 continue
170195 if not isinstance (spec , dict ):
171196 raise ConfigError (
172- f"{ self . _source_label () } : visual_map.{ sid } must be a YAML mapping, "
197+ f"{ src } : visual_map.{ sid_s } must be a YAML mapping, "
173198 f"not { type (spec ).__name__ } "
174199 )
175200
0 commit comments