Skip to content

Does the position of @run_after matter during decoration? #3833

Answered by alalazo
adamjstewart asked this question in Q&A
Discussion options

You must be logged in to vote

@adamjstewart That's because when you call @run_after or @run_before you register the function to be called back, for instance:

def run_after(*phases):
    """Registers a method of a package to be run after a given phase"""
    return PackageMeta.register_callback('run_after', *phases)

Now, if you "unroll" the second case to its semantically equivalent:

def check_install(self):
   pass

check = run_after('install')(check)  # Gets registered here
check = on_package_attribute(run_tests=True)(check)  # ... but also gets decorated after the registration

you see that the second decorator has no effect on the registered function. Maybe worth documenting?

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ashermancinelli
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3833 on December 20, 2020 23:52.