@@ -53,8 +53,8 @@ class AGONColumns(AGONFormat):
5353
5454 @staticmethod
5555 def hint () -> str :
56- """Return a short hint describing this format for LLMs ."""
57- return "AGON columns: arrays as name[N] with ├/└ field: val1, val2, ..."
56+ """Return a short hint instructing LLMs how to generate this format ."""
57+ return "Return in AGON columns format: Start with @AGON columns header, transpose arrays to name[N] with ├/└ field: val1, val2, ..."
5858
5959 @staticmethod
6060 def encode (
@@ -69,7 +69,7 @@ def encode(
6969 Args:
7070 data: JSON-serializable data to encode.
7171 delimiter: Value delimiter within columns (default: ", ").
72- include_header: Whether to include @AGON columns v1 header.
72+ include_header: Whether to include @AGON columns header.
7373 use_ascii: Use ASCII tree chars (|, `) instead of Unicode.
7474
7575 Returns:
@@ -210,7 +210,7 @@ def _encode_primitive(val: Any, delimiter: str) -> str:
210210 return "null"
211211 if isinstance (val , bool ):
212212 return "true" if val else "false"
213- if isinstance (val , ( int , float ) ):
213+ if isinstance (val , int | float ):
214214 if isinstance (val , float ):
215215 if val != val : # NaN
216216 return ""
@@ -267,7 +267,7 @@ def _is_columnar_array(arr: list[Any]) -> tuple[bool, list[str]]:
267267
268268 for obj in arr :
269269 for v in obj .values ():
270- if isinstance (v , ( dict , list ) ):
270+ if isinstance (v , dict | list ):
271271 return False , []
272272
273273 key_order : list [str ] = []
@@ -281,7 +281,7 @@ def _is_columnar_array(arr: list[Any]) -> tuple[bool, list[str]]:
281281
282282def _is_primitive_array (arr : list [Any ]) -> bool :
283283 """Check if array contains only primitives."""
284- return all (not isinstance (x , ( dict , list ) ) for x in arr )
284+ return all (not isinstance (x , dict | list ) for x in arr )
285285
286286
287287def _encode_value (
@@ -295,7 +295,7 @@ def _encode_value(
295295 """Encode a value, appending lines."""
296296 indent = INDENT * depth
297297
298- if val is None or isinstance (val , ( bool , int , float , str ) ):
298+ if val is None or isinstance (val , bool | int | float | str ):
299299 if name :
300300 lines .append (f"{ indent } { name } : { _encode_primitive (val , delimiter )} " )
301301 else :
@@ -389,7 +389,7 @@ def _encode_list_item_object(
389389 if isinstance (v , dict ):
390390 lines .append (f"{ prefix } { k } :" )
391391 for nk , nv in v .items ():
392- if isinstance (nv , ( dict , list ) ):
392+ if isinstance (nv , dict | list ):
393393 _encode_value (nv , lines , depth + 2 , delimiter , nk , use_ascii )
394394 else :
395395 lines .append (f"{ indent } { nk } : { _encode_primitive (nv , delimiter )} " )
@@ -417,7 +417,7 @@ def _encode_object(
417417 indent = INDENT * depth
418418
419419 for k , v in obj .items ():
420- if isinstance (v , ( dict , list ) ):
420+ if isinstance (v , dict | list ):
421421 _encode_value (v , lines , depth , delimiter , k , use_ascii )
422422 else :
423423 lines .append (f"{ indent } { k } : { _encode_primitive (v , delimiter )} " )
0 commit comments