[Python] In python argparse package when adding "formatter_class" MetavarTypeHelpFormatter the...

Discussão em 'Python' iniciado por Stack, Agosto 10, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using the python package argparse, with simple configuration

    When I try to add to my parser formatter_class=argparse.MetavarTypeHelpFormatter I get error:

    AttributeError: 'NoneType' object has no attribute '__name__'


    did anyone else encounter that? and maybe know why?

    this is my code:

    import argparse

    argParser = argparse.ArgumentParser(
    formatter_class=argparse.MetavarTypeHelpFormatter
    )

    argParser.add_argument("models", default='', nargs='+',
    help="Which model(s) to execute")


    args = argParser.parse_args()
    print(args)


    When I try it with out adding the formatter_class it is working It is also working with other formatter class like formatter_class=argparse.RawDescriptionHelpFormatter

    I also tried it with prog attribute and without

    Continue reading...

Compartilhe esta Página