Turn on ruff TRY003
Description
Turns the TRY003 error back on. I've done this because in the copier repo we have it on, and it wasn't obvious to me that we want that choice to go everywhere and pollute everything, but maybe I'm wrong.
The way I've ended up thinking about this:
- TRY003 is annoying, but it does make you think. In particular, about what your error messages are trying to say and whether they're reusable or not.
- I've landed at the point where I think there is a difference between an error message that can specify exactly what is wrong (e.g. I can't add a string and an int) vs. an error that says, "Something is wrong, but I can't diagnose any further what or why it has happened". TRY003 just makes you think a bit more about what your error is doing, so I think it's worth considering
- The error messages and classes I've implemented here might be overkill, but I think my future self will thank me. It's very helpful if the error message makes clear when it's an error with a known fix vs. being an error where we really don't know the solution, we just know something has led to a broken state.
- I think having TRY003 on also helps clarify when we're raising errors with really little idea about what is going on. If we reach for
noqa: TRY003, that basically signals that we know so little about this error that we can't even really name it or make it any more specific than just throwing whatever context we can at it and moving on.
However, I know this also might not be our preferred route and that the solution I've implemented isn't the most elegant thing in the world (I also don't think it's a disaster though). Anyway, I'm also happy to switch to just putting ignore statements through the fgen generated code instead.
Merge Request Steps
Please confirm that this pull request has done the following:
-
Tests added -
Documentation added (where applicable) -
Changelog item added to changelog/.
Edited by Zebedee Nicholls