@@ -374,14 +374,16 @@ def is_terminal_punctuation(char: str) -> bool:
374374 return char in ("." , "?" , "!" )
375375
376376
377- class ArgumentGroup :
377+ class ArgumentGroup ( argparse . _ArgumentGroup ) :
378378 """A wrapper for argparse's ArgumentGroup class that lets us enforce capitalization
379379 on the added arguments."""
380380
381381 def __init__ (self , argument_group : argparse ._ArgumentGroup ) -> None :
382382 self .argument_group = argument_group
383383
384- def add_argument (self , * name_or_flags , help = None , ** kwargs ) -> argparse .Action :
384+ def add_argument (
385+ self , * name_or_flags : str , help : str | None = None , ** kwargs : Any
386+ ) -> argparse .Action :
385387 if self .argument_group .title == "Report generation" :
386388 if help and help != argparse .SUPPRESS :
387389 ValueError (
@@ -408,8 +410,9 @@ def add_argument(self, *name_or_flags, help=None, **kwargs) -> argparse.Action:
408410 )
409411 return self .argument_group .add_argument (* name_or_flags , help = help , ** kwargs )
410412
411- def _add_action (self , action ) -> None :
412- self .argument_group ._add_action (action )
413+ def _add_action (self , action : Any ) -> Any :
414+ """This is used by the internal argparse machinery so we have to provide it."""
415+ return self .argument_group ._add_action (action )
413416
414417
415418class CapturableArgumentParser (argparse .ArgumentParser ):
@@ -431,8 +434,13 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
431434 # =====================
432435 # We just hard fail on these, as CI will ensure the runtime errors never get to users.
433436 def add_argument_group (
434- self , title : str , description : str | None = None , ** kwargs
437+ self , title : str | None = None , description : str | None = None , ** kwargs : str | Any
435438 ) -> ArgumentGroup :
439+ if title is None :
440+ raise ValueError (
441+ "CLI documentation style error: all argument groups must have titles,"
442+ + " and at least one currently does not."
443+ )
436444 if title not in [
437445 "positional arguments" ,
438446 "options" ,
0 commit comments