Does the position of @run_after matter during decoration? #3833
-
I was experimenting with adding an optional post-installation test to a package and noticed the following behavior. @run_after('install')
@on_package_attributes(run_tests=True)
def check_install(self): works as expected. The test is run post-installation, but only when @on_package_attributes(run_tests=True)
@run_after('install')
def check_install(self): instead, the tests are always run regardless of whether or not I supply |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
@adamjstewart That's because when you call 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:
you see that the second decorator has no effect on the registered function. Maybe worth documenting? |
Beta Was this translation helpful? Give feedback.
-
@adamjstewart I changed the title to reflect better what is being discussed here. Feel free to change it back if you disagree. |
Beta Was this translation helpful? Give feedback.
-
I think it's a bit too complicated to document this one. There's no way to just make it work? |
Beta Was this translation helpful? Give feedback.
-
@alalazo What if we changed the interface to: @run_after('install', run_tests=True)
def check_install(self): I'm not sure how the implementation details would work, but that would avoid a lot of unnecessary confusion. |
Beta Was this translation helpful? Give feedback.
@adamjstewart That's because when you call
@run_after
or@run_before
you register the function to be called back, for instance:Now, if you "unroll" the second case to its semantically equivalent:
you see that the second decorator has no effect on the registered function. Maybe worth documenting?