Skip to content

Instantly share code, notes, and snippets.

@bitprophet
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitprophet/16a273d07772207e6f9d to your computer and use it in GitHub Desktop.
Save bitprophet/16a273d07772207e6f9d to your computer and use it in GitHub Desktop.
#
# Option 1: can be more compact but lots of sigils, different arg types, maybe confusing
#
@task(pre={
'pretask1': None, # means no args
'pretask2': ['positional', 'args', 'in a list'],
'pretask3': {'keyword': 'args', 'in': 'a dict'},
})
def mytask():
pass
# Could also still give a list of pre-tasks, with implied "no args" invocation, as we do now
@task(pre=['pretask1', 'pretask2'])
def mytask2():
pass
#
# Option 2: use 1..N decorators so that it feels/looks more like a func call.
# but is now more verbose, and possible confusion re: @pre('task1', 'task2') not
# being a legal way to say 2 pre-tasks. Also possibly confusing if we continue to allow @task(pre=['task', 'names'])
#
@pre('pretask1') # No args
@pre('pretask2', 'positional', 'args')
@pre('pretask3', keyword='args')
@pre('pretask4', 'can now use', both='if desired')
@task
def mytask():
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment