Reformat using ruff #312
Labels
No labels
Closed As
Duplicate
Closed As
Fixed
Closed As
Invalid
discussions
easyfix
enhancement
task
ai-review-please
Backlog Status
Needs Review
Backlog Status
Ready
chore
documentation
points
01
points
02
points
03
points
05
points
08
points
13
pr2jira
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Sprint Status
Blocked
Sprint Status
Done
Sprint Status
In Progress
Sprint Status
Review
Sprint Status
To Do
Technical Debt
Work Item
Bug
Work Item
Epic
Work Item
Spike
Work Item
Task
Work Item
User Story
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Blocks
#306 Reformat codebase to satisfy CI linter check
quality/blockerbugs
Reference
quality/blockerbugs!312
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/306-2-ruff-reformat"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is just raw output of
ruff format .preconfigured to line length 100, no other changes were made.Tests are failing due to unrelated problem with missing sqlite libraries, fix was introduced in #311.
I scrolled through about half of this somewhat carefully then my eyes melted and I turbo-scrolled the rest. Couple of little notes but I think it's probably fine. It's 99% single quotes -> double quotes and rewrapping brace blocks. It might be interesting to try and separate those so we can see the less-common and possibly-more-interesting changes alone, but meh, not worth the effort most likely.
@ -21,2 +22,3 @@target_metadata = db.metadata#target_metadata = None# target_metadata = Noneprobably this line can just be removed?
I proposed the whole
alembic/to be excluded.But in general, this is a config file, so I assume the commented out value is the original default value, so there's slight value in it.
@ -129,2 +132,2 @@"full-revisionid": None,"dirty": False, "error": None, "date": None}return {"version": dirname[len(parentdir_prefix) :],not sure I love how it adds a space to this construct (it does it in several more places below), but if it's too much trouble to stop it doing that I guess we can live with it.
Ugh, that is ugly. This file should also be excluded, but it does the same e.g. in
blockerbugs/__init__.py:152:I played with it a little, this is how ruff likes things:
I guess it does make some sense, but looks very unusual to me.
True to its name, there's no configuration option for it.
@ -194,3 +190,4 @@raise ValidationError("%s invalid input string" % (self.name))class UrlValidator(BaseValidator):not really related to this PR, but wow, we should outsource this
@ -62,3 +63,3 @@# There are two options for replacing |today|: either, you set today to some# non-false value, then it is used:#today = ''# today = ''maybe change these to double quotes for consistency? ditto below
Yet another config file where auto-formatting doesn't make sense, in my opinion.
ba948794898ae4acc4e8I've rebased this since I merged the sqlite-devel test fix into develop.
Some files need to be excluded, as pointed out in #311. So I'm marking that now as a change request. Will continue with the review in the meantime.
@adamwill wrote in #312 (comment):
So why don't we set
quote-style = "preserve"? I know you hate inconsistency, but I don't see any downside in this, just upsides (not changing lines which don't need to be changed).There are almost zero config options for black and ruff formatting, yet this is one of the very exceptions to the rule that ruff has. There has to be a good reason for it.
I did that in #314
I left some of my comments in #314. Overall it's fine (I guess...), except a couple of places where I really don't like the new vertical sprawl. Argparser definitions, testdata definitions, and tests themselves (sometimes).
The docs are not currently reformatted. Since we're going through this, I'd really like to redo them as well. Should it be a part of this PR (as yet another commit), or another PR, any preferences?
@kparal wrote in #312 (comment):
I am fine with using single-quote string delimiter for this repo since the majority of code is using that.
@kparal wrote in #312 (comment):
I am not sure how to proceed here.
ruffformatter cannot be configured to produce such output. So I guess we drop the reformat and just fix linter problems? (I am fine with either outcome).@kparal wrote in #312 (comment):
AFAIK
ruffdoes not format docs so we should probably leave it to a completely different ticket. We could use tools likerstcheckandmdlintfor that.No, I wrote that mostly to receive your feedback, e.g. "yes it makes sense to suppress autoformat in these cases" or "no, you still can't appreciate the clarify it brings, let's reformat everything!" 😉️ Once we agree, we can suppress autoformat in certain parts of the file like this:
https://docs.astral.sh/ruff/formatter/#format-suppression
Sorry, by "docs" I meant docstrings+comments. Here I suggested trying
docformatterfor it. But I can also do it manually if needed. My goal is to use the full maximum line length (currently proposed for 100 chars) even for docstrings and comments, so that we eliminate some of that vertical sprawl that ruff is going to create.Sigh, it doesn't seem to work correctly, at least in my attempts. So I guess I'll reflow it manually. But that will be a separate commit.
@kparal wrote in #312 (comment):
Oh, I see! Well, as I said, I do not have any problem even with no formatting at all so if such carve-outs are good enough for you, I say let's go for it! The question is how we will identify all such places in this large codebase?
OK, then. I guess another PR would be useful for that. I am really interested whether it would make a big difference to reformat docstrings.
I reviewed it all already. The parts that I pointed out in #314 were the only ones that caught my attention. Once I learn Adam's opinion, I might try to suppress some parts of those files.
I finally figured out that the bestest tool to understand and reformat docstrings and comments is... AI. It naturally understands it, so it reformats just the parts that need it. I'll prepare the PR.
I don't expect that many lines saved, to be honest. But just as some things provoke's Adam's perfectionism, some things provoke mine 😀️ If we're changing almost the whole codebase, we might as well do it completely...
But, I figured that perhaps we can use this step to actually sync the docstrings style. Some of our methods use Epytext, some Rest, some Google style. AI seems capable of rewriting it into a single style (I think Google is the best, now that we have type hints directly in method definitions). So I'll try to create a PR that also does that. So this will have more benefits than just basic reflowing.
@adamwill I might regret asking, but do you have any opinion on
quote-style = "preserve"and my points from #314?I personally like having double quotes everywhere as it means I don't have to mentally adjust from project to project, but it's not a big deal. For 314, I replied there.
8ae4acc4e874eeb269ffThis is the final output. In the end, I didn't use any
fmt: offorfmt:skiplines. Please give thumps up to approve. This can be merged once #311 is merged (and this will be rebased on top of it).LGTM
74eeb269ffde4c2ba778