docstringargs: Python module for setting up argparse

Paul Rubin at nospam.invalid
Tue Apr 21 06:33:28 CEST 2015

Chris Angelico <rosuav at> writes:
> @cmdline
> def adduser(
>         user: {cmdline: "Name of user to add", typing: str},
>         password: {cmdline: "Password for the new user", typing: str}=""):
>     """Add a new user"""

In the case of just one decorator, the dictionary could be omitted.  The
decorator function itself could have an annotation flagging it as a
consumer of annotations, so that would make it easy to check if there
was more than one.  In your example above, you'd also want a @typing

In those particular cases, the decorators don't even need the annotation

@cmdline(name="Name of user to add", password="Password for the new user")
@typing(name=str, password=str)
def adduser(user, password):
    """Add a new user"""

More information about the Python-list mailing list