Repository navigation
Reject NaN as a MockClock rate - #3562
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3562 +/- ##
===============================================
Coverage 100.00000% 100.00000%
===============================================
Files 128 128
Lines 19479 19484 +5
Branches 1323 1323
===============================================
+ Hits 19479 19484 +5
🚀 New features to boost your workflow:
|
A5rocks
left a comment
There was a problem hiding this comment.
Please don't respond with LLM-generated comments or I will close this PR!
| @rate.setter | ||
| def rate(self, new_rate: float) -> None: | ||
| if new_rate < 0: | ||
| if not new_rate >= 0: # also rejects NaN |
There was a problem hiding this comment.
Please make this explicit. math.isnan exists, we don't have to do stupid transformations on math to check for NaN! Also a better error message is possible.
|
Hey @56steve, it looks like that was the first time we merged one of your PRs! Thanks so much! 🎉 🎂 If you want to keep contributing, we'd love to have you. So, I just sent you an invitation to join the python-trio organization on Github! If you accept, then here's what will happen:
If you want to read more, here's the relevant section in our contributing guide. Alternatively, you're free to decline or ignore the invitation. You'll still be able to contribute as much or as little as you like, and I won't hassle you about joining again. But if you ever change your mind, just let us know and we'll send another invitation. We'd love to have you, but more importantly we want you to do whatever's best for you. If you have any questions, well... I am just a humble Python script, so I probably can't help. But please do post a comment here, or in our chat, or on our forum, whatever's easiest, and someone will help you out! |
MockClock accepted a NaN rate because the check was
new_rate < 0, which is false for NaN, soMockClock(rate=float('nan')).current_time()returned nan. I changed the check so NaN raises the same ValueError as a negative rate, and added tests for both the constructor and the setter.