@@ -399,7 +399,6 @@ class DropShorterLongHelpFormatter(argparse.HelpFormatter):
399399
400400 - Collapse **long** options that are the same except for extra hyphens.
401401 - Shortcut if there are only two options and one of them is a short one.
402- - Cache result on the action object as this is called at least 2 times.
403402 """
404403
405404 def __init__ (self , * args : Any , ** kwargs : Any ) -> None :
@@ -412,13 +411,9 @@ def _format_action_invocation(self, action: argparse.Action) -> str:
412411 orgstr = super ()._format_action_invocation (action )
413412 if orgstr and orgstr [0 ] != "-" : # only optional arguments
414413 return orgstr
415- res : str | None = getattr (action , "_formatted_action_invocation" , None )
416- if res :
417- return res
418414 options = orgstr .split (", " )
419415 if len (options ) == 2 and (len (options [0 ]) == 2 or len (options [1 ]) == 2 ):
420416 # a shortcut for '-h, --help' or '--abc', '-a'
421- action ._formatted_action_invocation = orgstr # type: ignore
422417 return orgstr
423418 return_list = []
424419 short_long : dict [str , str ] = {}
@@ -441,9 +436,7 @@ def _format_action_invocation(self, action: argparse.Action) -> str:
441436 return_list .append (option )
442437 if option [2 :] == short_long .get (option .replace ("-" , "" )):
443438 return_list .append (option .replace (" " , "=" , 1 ))
444- formatted_action_invocation = ", " .join (return_list )
445- action ._formatted_action_invocation = formatted_action_invocation # type: ignore
446- return formatted_action_invocation
439+ return ", " .join (return_list )
447440
448441 def _split_lines (self , text , width ):
449442 """Wrap lines after splitting on original newlines.
0 commit comments