@@ -104,12 +104,6 @@ def __init__(self) -> None:
104104 raise NotImplementedError
105105
106106 def _to_json (self ) -> J :
107- """
108- Turns this option into a JSON value.
109-
110- Returns:
111- This option's JSON representation.
112- """
113107 return self .value
114108
115109 def __post_init__ (self ) -> None :
@@ -364,12 +358,6 @@ class ButtonOption(BaseOption):
364358 on_press : Callable [[Self ], None ] | None = None
365359
366360 def _to_json (self ) -> EllipsisType :
367- """
368- A dummy method to adhere to BaseOption interface, while indicating no JSON representation.
369-
370- Returns:
371- Ellipsis, indicating that ButtonOption cannot be represented as a value.
372- """
373361 return ...
374362
375363 def _from_json (self , value : JSON ) -> None :
@@ -479,12 +467,11 @@ class GroupedOption(BaseOption):
479467 children : Sequence [BaseOption ]
480468
481469 def _to_json (self ) -> JSON :
482- grouped_option_dict : Mapping [str , JSON ] = {}
483- for option in self .children :
484- if option ._to_json () == ...:
485- continue
486- grouped_option_dict [option .identifier ] = cast (JSON , option ._to_json ())
487- return grouped_option_dict
470+ return {
471+ option .identifier : child_json
472+ for option in self .children
473+ if (child_json := option ._to_json ()) is not ...
474+ }
488475
489476 def _from_json (self , value : JSON ) -> None :
490477 if isinstance (value , Mapping ):
@@ -523,12 +510,11 @@ class NestedOption(BaseOption):
523510 children : Sequence [BaseOption ]
524511
525512 def _to_json (self ) -> JSON :
526- grouped_option_dict : Mapping [str , JSON ] = {}
527- for option in self .children :
528- if option ._to_json () == ...:
529- continue
530- grouped_option_dict [option .identifier ] = cast (JSON , option ._to_json ())
531- return grouped_option_dict
513+ return {
514+ option .identifier : child_json
515+ for option in self .children
516+ if (child_json := option ._to_json ()) is not ...
517+ }
532518
533519 def _from_json (self , value : JSON ) -> None :
534520 if isinstance (value , Mapping ):
0 commit comments