Skip to content

@task doesn't play nice with other decorators #555

@lsh-0

Description

@lsh-0

The @task decorator doesn't appear to play nicely with other decorators, unlike Fabric. I may not have read this part of the documentation yet, but I wouldn't expect @task to undermine python norms.

For example:

def capture_error(fn):
    @wraps(fn)
    def wrapper(*args, **kwargs):
        try:
            return fn(*args, **kwargs)
        except AssertionError as err:
            print(err)
    return wrapper

@task
@capture_error
def foo(c):
    print('bar')
    raise AssertionError('baz')

this looks fine:

inv foo
>>> bar
>>> baz

but when I add a parameter:

@task
@capture_error
def foo(c, p1):
    print(p1)
    raise AssertionError('baz')

I get:

inv foo bar
>>> No idea what 'bar' is!

The parameter handling docs offer no insight into what the problem is.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions