argparse subparser with required=True still runs with no subcommand
Python 3.9 here. I set up subparsers with add_subparsers(dest='cmd', required=True) but running python app.py with no args just exits 0 and does nothing. Shouldn't required=True error out? I added it because I saw it in the docs. Maybe I'm on too old a version, or maybe the flag does something else entirely and I misread it. I'd rather not add a manual if not args.cmd: parser.error(...) check if the built-in is supposed to handle it.
4 replies