fix: replace bare except with except Exception in useragent.py#7296
fix: replace bare except with except Exception in useragent.py#7296harshadkhetpal wants to merge 1 commit intovoxel51:developfrom
Conversation
Bare `except:` catches all exceptions including SystemExit, KeyboardInterrupt and GeneratorExit. Using `except Exception:` is more precise and follows Python best practices (PEP 8). Fixes #noissue
|
Thanks for opening this pull request, @harshadkhetpal! 🎉 A maintainer will review your changes soon. In the meantime, please ensure:
Helpful resources: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughUpdated exception handling in Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@harshadkhetpal think you can push changes to all the bare except locations in the source for consistency? I found at least 176 occurrences on the grep -rn "^\s*except\s*:" --include="*.py" fiftyone/All bare exceptions found
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #7296 +/- ##
===========================================
+ Coverage 99.10% 99.25% +0.15%
===========================================
Files 85 101 +16
Lines 23353 29047 +5694
===========================================
+ Hits 23143 28830 +5687
- Misses 210 217 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Replace bare
except:withexcept Exception:infiftyone/utils/useragent.py.Bare
except:silently catches all exceptions — includingSystemExit,KeyboardInterrupt, andGeneratorExit— which can suppress critical signals and make programs impossible to interrupt.except Exception:is the correct, Pythonic choice when the intent is to swallow non-fatal errors.Change:
Testing
No behavior change — style/correctness fix only. The
passblock continues to swallow non-fatal exceptions while correctly allowingSystemExitandKeyboardInterruptto propagate.Summary by CodeRabbit