-
Notifications
You must be signed in to change notification settings - Fork 384
Description
I.e.:
@task
def pretask():
pass
@task(pre='pretask')
def realtask(arg):
passThis will fail because at the bottom of Executor.execute() we build a task list and then give all of them the CLI arguments. I.e. pre/post tasks are given the same input as the "main" task.
The API we would need to fix this is probably:
@task
def pretask():
pass
@task(pre={'pretask': []})
def realtask(arg):
passOr, with a pretask that has an interesting signature:
@task
def pretask(myarg):
pass
@task(pre={'pretask': ['foo']})
def realtask(arg):
passWould be equivalent to calling pretask('foo') prior to calling realtask().
Allowing a dict for keyword args would also make sense; however the full implementation would want both an args list and a kwargs dict, which would then both need wrapping in a tuple or list. That gets pretty fugly pretty fast:
@task(pre={'pretask': ([], {'kwarg': 'value'}})Another possibility (this is actually what nate-pycon on IRC originally thought of) is to reuse the parser and say e.g.:
@task(pre=['pretask --kwarg=value'])However I think even the most complex pure-Python version above is preferable, because:
- it's not sufficient to be the ONLY way of doing this, because forcing a serialize/deserialize step when pure Python is much faster/easier;
- if we make it just another alternative, that's almost definitely crossing my "too many ways to do it -> confusing and overly complex code" threshold