-
Notifications
You must be signed in to change notification settings - Fork 972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a decorator #148
Added a decorator #148
Conversation
Can you write pls how to use this decorator? Thanks |
Thanks RHagenaars for creating this PR. To tell you the truth I'm on the fence whether this should be a part of schedule itself or an FAQ item. A couple of thoughts here:
|
@Naramsim the usage would be as follows:
@dbader thanks for taking time to consider it. About your thoughts:
That's not necessary in this case. If you look closely, you'll see that the actual decorated function is returned and not some wrapper.
Good catch! I've added that import.
I'm not sure how to fix that. Could you elaborate some more on what exactly needs to be fixed? I took the docstring on top of the file for an example.
That's up to you of course. I personally like decorators for things like this, because it allows you to put coupled statements - the function and the schedule - close to each other. I think that in most cases, the code is more clear when these are not separated. |
Hi @RHagenaars, Thanks a lot for submitting this pr! I'm thrilled to add this to the library 💯 Just now I've added support for passing arguments to the function via the decorator. And I've added some examples to the docs. Would you like to let me know what you think of this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, @SijmenHuizenga ! I really like the addition of passing arguments.
Co-authored-by: Ramon Hagenaars <ramonhagenaars@gmail.com>
Thanks for the review @RHagenaars! Let's merge 🚀 |
* Added 'repeat' decorator and written a test. Increased the version by 0.0.1. * Removed the type of the given job for python 2.* compatibility. * Added some newlines to comply with FLAKE8 * Added import for 'repeat' in the code example * Added decorator docs and the ability to pass arguments to the job through the decorator * Fix FLAKE8 * Added rhagenaars to authors * Apply suggestions from code review
I've added a decorator for conveniently defining jobs from functions.