-
Notifications
You must be signed in to change notification settings - Fork 964
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
Add assertion error messages #271
Conversation
Using if not condition:
raise ScheduleError(...) Where
(or a wrapper around another appropriate Python internal error class) |
Is something like this what you were thinking? |
Yep :) |
2 lines around each class
Invalid units
Sorry!! 😧
The regular expression above makes it impossible to have a number above 59 or below 0, so these exceptions can never be raised
Accidentally added when reverting
For some reason coverage dropped?
Did you want the assertRaises to also be changed to pytest's version? Otherwise, I believe there is nothing else to do for this pr :^) |
schedule/__init__.py
Outdated
class CancelJob(object): | ||
""" | ||
Can be returned from a job to unschedule itself. | ||
""" | ||
pass |
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.
What happened here? Let's leave the pass
in to make sure we communicate that this should be an empty class. (Same above on the various error classes, just a stylistic thing)
Thanks! The I just hope people weren't catching |
And please add yourself to the contributors file (if you want) |
schedule/__init__.py
Outdated
@@ -368,16 +399,15 @@ def at(self, time_str): | |||
second = 0 | |||
if self.unit == 'days' or self.start_day: | |||
hour = int(hour) | |||
assert 0 <= hour <= 23 | |||
if 0 > hour or hour > 23: |
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.
Let's keep the condition the same for the checks. I know they're equivalent but I like 0 <= hour <= 23
better :P
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.
I agree!! But I couldn't figure out how to make them equivalent using that without making it
if not (0 <= hour <= 23)
and I thought it was harder to read.
Do you think it should just be if not (0 <= hour <= 23)
?
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.
Do you think it should just be if not (0 <= hour <= 23) ?
Mmmh yeah I think that's still easier to read :)
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.
:^)
Gave this another review and found some more stuff, can you comment on those? |
I forgot to save the file 😧
Functionally the same, but (hopefully) more readable
LGTM! 🎉 Nice work @connorskees! |
This is now live in https://pypi.org/project/schedule/0.6.0/ |
Fixes #270 (comment)