docstringargs: Python module for setting up argparse
no.email at nospam.invalid
Tue Apr 21 07:54:39 CEST 2015
Chris Angelico <rosuav at gmail.com> writes:
> Other decorators have to be able to recognize whether there's an outer
> dictionary or not. That means they have to dig into the annotating
> object to inquire as to whether or not their thing is there.
I'm imagining the annotation consumers themselves being wrapped by
something that handles that automatically:
def cmdline(**args): ...
This turns cmdline into something that takes the function object, peels
off the cmdline annotations, and gives them to the function in the def.
There is still the issue of figuring out when there is just one
consumer, or more generally, identifying the outermost one. But it
should be possible to come up with something. Is there a metaclass for
functions that can notice when a def or decorator is run, or anything
>> would have been caught immediately by the type checker
> Assuming you run it immediately.
I thought the idea of type checking is that it's run at compile time.
Maybe not as soon as the decorator is seen, since type info has to
propagate through the whole program before checking can finish, but it
gets caught when the checker runs.
More information about the Python-list