ruff
ruff copied to clipboard
Implement `tryceratops`
- [x] TC002: Create your own exception
- [x] TC003: Avoid specifying long messages outside the exception class
- [x] TC004: Prefer TypeError exception for invalid type
- [ ] TC100: Check to continue
- [ ] TC101: Too many try blocks
- [x] TC200: Use raise Exception from
- [x] TC201: Simply use raise
- [ ] TC202: Don't ignore a broad exception without even logging
- [x] TC300: Consider adding an else block
- [x] TC301: Avoid direct raises in try body
- [x] TC400: Use logging .exception instead of .error
- [ ] TC401: Do not log the exception object
Taking TC201
For tracking: I'm working on TC004
@charliermarsh, i would like to do TC200.
Awesome -- thanks all! Will review as they come in :)
I'll take TC301 next.
I'd like to implement TC400, which would be my first rule so it might take a few days. Would that be fast enough ?
@Flowake - Sure! Take your time. Feel free to open a draft PR and ask questions there if you run into any.
I'll take TC002 next.
Ciao, I'm testing the new implementation, but I'm getting this error: TRY300 Consider else block
![Screenshot 2023-01-26 at 22 16 04](https://user-images.githubusercontent.com/1511095/214952122-ab8ea72f-51a7-400a-bd00-59f5eebd1427.png)
Isn't it a false positive? Thanks so much
Hmm, comparing to the original plugin, I think what's incorrect is the highlighted region. It seems to want you to do this (omitting some intermediary lines since I had to copy from the screenshot :)):
try:
assert isinstance(value, list) is False
except Exception as exc:
msg = ""
raise EnsureStrException(msg)
else:
return str(value)
(Fixed in #2228.)
Superb, thanks!
@charliermarsh me and luca should buy you lunch in BKL - ping me on linkedin or whatever and I'm happy to buy you lunch. Thanks for all the great work!
Taking TC401 and TC202