Skip to content

Pass custom HelpFormatter to subparsers #336

Closed
@zrlf

Description

@zrlf

When using a custom HelpFormatter, subparsers are still using the default SimpleHelpFormatter.

To Reproduce

from simple_parsing import ArgumentParser
from dataclasses import dataclass

@dataclass
class Sub:
   foo: str

@dataclass
class Foo:
   subcommand: Union[Sub, SomeOther]
   bar: int = 123

if __name__ == "__main__":
   parser = ArgumentParser(formatter_class=CustomHelpFormatter)
   parser.add_arguments(Foo, "foo")
   args = parser.parse_args(["sub", "-h"])

Expected behavior
Any subparser should inherit the formatter.

Actual behavior
Default is used

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions