@@ -169,8 +169,7 @@ def _describe_application(self, application: Application, **options: Any) -> Non
169169
170170 self ._describe_definition (Definition (application .definition .options ), ** options )
171171
172- self ._write ("\n " )
173- self ._write ("\n " )
172+ self ._write ("\n \n " )
174173
175174 commands = description .commands
176175 namespaces = description .namespaces
@@ -181,7 +180,7 @@ def _describe_application(self, application: Application, **options: Any) -> Non
181180 commands [name ] = description .command (name )
182181
183182 # calculate max width based on available commands per namespace
184- all_commands = list (commands . keys () )
183+ all_commands = list (commands )
185184 for namespace in namespaces .values ():
186185 all_commands += namespace ["commands" ]
187186
@@ -223,23 +222,18 @@ def _describe_application(self, application: Application, **options: Any) -> Non
223222 self ._write ("\n " )
224223
225224 def _format_default_value (self , default : Any ) -> str :
226- new_default : Any
227225 if isinstance (default , str ):
228226 default = Formatter .escape (default )
229227 elif isinstance (default , list ):
230- new_default = []
231- for value in default :
232- if isinstance (value , str ):
233- new_default .append (Formatter .escape (value ))
234-
235- default = new_default
228+ default = [
229+ Formatter .escape (value ) for value in default if isinstance (value , str )
230+ ]
236231 elif isinstance (default , dict ):
237- new_default = {}
238- for key , value in default .items ():
239- if isinstance (value , str ):
240- new_default [key ] = Formatter .escape (value )
241-
242- default = new_default
232+ default = {
233+ key : Formatter .escape (value )
234+ for key , value in default .items ()
235+ if isinstance (value , str )
236+ }
243237
244238 return json .dumps (default ).replace ("\\ \\ " , "\\ " )
245239
@@ -261,7 +255,7 @@ def _calculate_total_width_for_options(self, options: list[Option]) -> int:
261255 return total_width
262256
263257 def _get_column_width (self , commands : Sequence [Command | str ]) -> int :
264- widths = []
258+ widths : list [ int ] = []
265259
266260 for command in commands :
267261 if isinstance (command , Command ):
@@ -278,10 +272,9 @@ def _get_column_width(self, commands: Sequence[Command | str]) -> int:
278272 return max (widths ) + 2
279273
280274 def _get_command_aliases_text (self , command : Command ) -> str :
281- text = ""
282275 aliases = command .aliases
283276
284277 if aliases :
285- text = f"[{ '|' .join (aliases ) } ] "
278+ return f"[{ '|' .join (aliases ) } ] "
286279
287- return text
280+ return ""
0 commit comments