-
Notifications
You must be signed in to change notification settings - Fork 0
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 ruff specs #6
Comments
I would not turn on any automatic reformatting, because my experience with that is that it destroys your code. Even just with the linter there are some in the defaults that I don't like. The one that I have the most trouble with is E402: https://docs.astral.sh/ruff/rules/module-import-not-at-top-of-file/ While that sounds like a good idea, it's not practical. We have to use various libraries, and some of them behave badly. For example, the NOIRlab queryClient library dies on import if there isn't a I am morally opposed to E201 and E202 (no whitespace after open bracket or before close bracket). I know PEP-8 says that you're not supposed to have whitespace there, but PEP-8 opens with "a foolish consistency is the hobgoblin of small minds". (This to my mind is the problem with code formatters in general, and part of why I hate black so much; they value mindless consistency over readability.) I find that unless the call is short (shortish function name, single shortish parameter), it's way more readable to have a space after the opening parentheses and before the closing parentheses. (Whitespace can really improve readability.) In general with linter rules, there are two issues. The first is, if we're going to make some of these things errors that prevent committing to the archive or merging to main, then they're too restrictive. Even if they're just warnings that the user has to read, "warning fatigue" with lots of feedback that's not actually important means that people's eyes are going to glaze over and they're going to miss the things that really do matter. So, as a general suggestion, I'd say that we pick the things that really matter, and focus on that. Many of the ruff defaults are fine, but I'd want to spend some time really thinking about all of them before I'd be happy turning them on. I would also not have it do any automatic reformatting. Flag the style problems, and then either suggest or require that the programmer fix them themselves. Sometimes there's a good reason for violating a formatting rule, and automatic reformatting doesn't understand that. We do have to realize that if we pick stuff now, it could make life harder if we want to add a restriction later, unless it's one that's not already violated very often. |
I would like to turn on W291, which detects trailing whitespace at the end of a line. |
Great feedback @rknop, this will help us figure out what we do want in there. This goes along with deciding on pre-commit use too :) |
OK, I have an extensive list of things that I would include. For a completely different project (the LS4 pipeline), I put these in to see how they'd do with code that I wrote a lot of (and that some other people did some of). This may be too many things, and may cause too much pain. First, here's the ruff.toml that I'm currently using for that other project:
Here is the notes I made reading through the RUFF rules. I do have to admit that my eyes glazed over for a while reading through some of the 800 rules, and I kind of skipped some categories...
|
E703 is the "have you been writing a webap and going back and forth between JavaScript and Python a lot" check.... |
I am good with this list. Do we want it in pyproject.toml or ruff.toml? |
We need to decide on the set of specs we want to use with ruff and add them to the template
The text was updated successfully, but these errors were encountered: