@@ -102,22 +102,15 @@ def format_epilog(self, epilog: str | None) -> str:
102102 return ""
103103
104104 def rich_expand_default (self , option : optparse .Option ) -> Text :
105- # `HelpFormatter.expand_default()` equivalent that returns a `Text`.
106- assert option .help is not None
107- if self .parser is None or not self .default_tag :
108- help = option .help
109- else :
110- default_value = self .parser .defaults .get (option .dest ) # type: ignore
111- if default_value is optparse .NO_DEFAULT or default_value is None :
112- default_value = self .NO_DEFAULT_VALUE
113- help = option .help .replace (self .default_tag , escape (str (default_value )))
105+ """Equivalent to HelpFormatter.expand_default() but with Rich support."""
106+ help = escape (super ().expand_default (option ))
114107 rich_help = Text .from_markup (help , style = "optparse.help" )
115108 for highlight in self .highlights :
116109 rich_help .highlight_regex (highlight , style_prefix = "optparse." )
117110 return rich_help
118111
119112 def format_option (self , option : optparse .Option ) -> str :
120- # Overridden to call the rich methods.
113+ """ Overridden method with Rich support."""
121114 result : list [Text ] = []
122115 opts = self .rich_option_strings [option ]
123116 opt_width = self .help_position - self .current_indent - 2
@@ -147,7 +140,7 @@ def format_option(self, option: optparse.Option) -> str:
147140 return self .stringify (Text ().join (result ))
148141
149142 def store_option_strings (self , parser : optparse .OptionParser ) -> None :
150- # Overridden to call the rich methods.
143+ """ Overridden method with Rich support."""
151144 self .indent ()
152145 max_len = 0
153146 for opt in parser .option_list :
@@ -168,7 +161,7 @@ def store_option_strings(self, parser: optparse.OptionParser) -> None:
168161 self .help_width = max (self .width - self .help_position , 11 )
169162
170163 def rich_format_option_strings (self , option : optparse .Option ) -> Text :
171- # ` HelpFormatter.format_option_strings()` equivalent that returns a `Text`.
164+ """Equivalent to HelpFormatter.format_option_strings() but with Rich support."""
172165 opts : list [Text ] = []
173166
174167 if option ._short_opts :
0 commit comments