mosquito / argclass

A wrapper around the standard argparse module that allows you to describe argument parsers declaratively
Apache License 2.0
12 stars 3 forks source link

Required option for argument is not inherited, inconsistent and not expected behaviour #21

Open alvassin opened 6 months ago

alvassin commented 6 months ago

In the following example i expect all arguments to be required:

import argclass

class BaseParser(argclass.Parser):
    argument1: str  # not ok, not required
    argument2: str = argclass.Argument(required=True)  # ok

class SuperParser(BaseParser):
    argument3: str  # ok

parser = SuperParser()
parser.parse_args()

Output:

usage: scratch_1.py [-h] [--argument1 ARGUMENT1] --argument2 ARGUMENT2
                    --argument3 ARGUMENT3
scratch_1.py: error: the following arguments are required: --argument2, --argument3