Skip to content

Error with subparsers if there are no arguments provided #2

@khud

Description

@khud
import typedparse
def f1(name: str):
    """f1
    :param name: name
    :return: None
    """
def f2(name: str):
    """f2
    :param name: name
    :return: None
    """
if __name__ == "__main__":
    typedparse.parse([f1, f2])

causes an error if we start the script without arguments:

python ./tt.py
Traceback (most recent call last):
  File "./tt.py", line 20, in <module>
    typedparse.parse([f1, f2])
  File "/home/ilya/HORIS/Projector/github/tptest/venv/lib/python3.6/site-packages/typedparse/__init__.py", line 41, in parse
    )).create(obj).parse()
  File "/home/ilya/HORIS/Projector/github/tptest/venv/lib/python3.6/site-packages/typedparse/argparse.py", line 24, in parse
    args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

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