docstringargs: Python module for setting up argparse

Chris Angelico rosuav at gmail.com
Mon Apr 20 21:19:27 EDT 2015


On Tue, Apr 21, 2015 at 11:13 AM, Paul Rubin <no.email at nospam.invalid> wrote:
> Chris Angelico <rosuav at gmail.com> writes:
>> @cmdline
>> def adduser(user: "Name of user to add", password: "Password for the
>> new user"=""):
>>     """Add a new user"""
>
> Does this conflict with type signature proposals using that annotation
> mechanism?  I guess that means PEP 0484 but I've lost track of what's
> where.

In the sense that you can't use both together, yes. But docstringargs
follows the rule of "if you're going to use annotations, also use a
decorator"; and the decorator removes all the annotations it uses. In
any case, functions designed to be given arguments via docstringargs
will always be getting strings or True/False (and the latter only if
you explicitly say so), so annotating parameter types won't help much
(and an annotated return value is ignored by docstringargs and can be
permitted through).

ChrisA



More information about the Python-list mailing list