-
-
Notifications
You must be signed in to change notification settings - Fork 346
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 a sanity check for a missing derive
for exception groups
#3176
Add a sanity check for a missing derive
for exception groups
#3176
Conversation
Seems rather expensive to put in |
Maybe the runtime cost is too high yeah.
That's the only place in trio where we call |
2a14f10
to
d8e853f
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3176 +/- ##
====================================================
- Coverage 100.00000% 99.98920% -0.01081%
====================================================
Files 124 124
Lines 18458 18510 +52
Branches 1215 1222 +7
====================================================
+ Hits 18458 18508 +50
- Misses 0 1 +1
- Partials 0 1 +1
|
I'm on the fence on whether we should check for this at runtime at all, esp when it gets this messy. And making people add On the other hand this would catch cases in libraries not running an appropriate linter, and an end user using that library+trio. But the error doesn't feel very trio-specific in the first case. |
Actually this would false positive if someone mirrors the BaseExceptionGroup<->ExceptionGroup structure (where only BaseExceptionGroup has a derive)... So maybe this isn't that useful of something to always warn about. I don't think everyone uses linters but I suppose if someone needs a custom ExceptionGroup odds are they use a linter? |
I don't think this is Trio's job to detect, especially since the implementation is complicated and likely to be slow. I would much prefer to see us address the hazard with a lint, and/or a CPython change to warn in |
I do think it's trio's place to try to prevent footguns (or even common mistakes) and I do think this qualifies. But I'll close this because:
Mostly the second reason though. If someone comes up with a runtime thing that does better, I would love another attempt at this -- I totally could see myself ignoring documentation when playing around with a new thing (given I don't have linting in my REPL and I don't run lints until committing). |
Fixes #3175, probably.
Just adds a sanity check. I started thinking about doing our own
.split()
but then I decided that's a lot. I also looked at just using.derive
at the end but the exception groups without.derive()
can be anywhere in the exception group contents.I made python-trio/flake8-async#334 for the linter rule side of this, but I think this is probably easy enough to forget especially if trying out this feature (and easy to overlook).