-
-
Notifications
You must be signed in to change notification settings - Fork 81
unwatch no longer logs a warning and idempotent behavior clarified
#1018
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
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1018 +/- ##
==========================================
- Coverage 87.27% 87.04% -0.23%
==========================================
Files 9 9
Lines 4936 4941 +5
==========================================
- Hits 4308 4301 -7
- Misses 628 640 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@jlstevens I believe you're the last person who refactored |
|
After thinking about this, I think raising a
I believe the original intent was to make unwatching idempotent: if you ask for something to be unwatched and it exits, it gets unwatched. If it is not being watched already, then there is nothing to do. I see arguments either way and I don't mind this behavior being deprecated, but not this suddenly. |
|
Thanks for the review @jlstevens, beneficial insights. After giving it some more thought, I decided it was best to stay closer to the current implementation that aims to be idempotent. I say "aim" as it is not truly idempotent imo as it logs a warning when the watcher has already been removed. I agree there are situations in an app, even more so when it's async based, where unwatching can happen multiple times or in a non-specific order. FWIW what also pushed me to change things was that the try/except was just catching With 016b675:
@jlstevens could you please review again? |
|
Seems you came round to my original way of thinking after all :-) 016b675 looks fine to me: looks like the difference is that there is no more warning. I think I am fine with this: you can now sprinkle repeated The original thought about the logging is that a well designed app would keep track of what is being watched/unwatched carefully and make sure to pair watch/unwatch properly, issuing a warning to the user if However, by declaring Lastly, note that while I think this is fine, this is my somewhat subjective take on the issue. Maybe other people hate this behaviour but my instinct is that this is fairly sensible! |
unwatch no longer logs a warning and idempotent behavior clarified
Resolves #1003
By raising
ValueErrorwhen trying to remove an already removed/never registered watcher.