Skip to content

Lint: Use Ruff to format Tools/jit #133123

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

Conversation

AA-Turner
Copy link
Member

It doesn't make that much sense to use two linters in our source tree. This switches Tools/jit and Tools/build/check-warnings.py to use Ruff for their formatting, which has the side benefit of slightly speeding up pre-commit and the lint CI job.

A

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me, but please get sign-off from the people maintaining these directories (I am not!)

Comment on lines +237 to +245
case (
Hole(
offset=offset,
kind="IMAGE_REL_AMD64_REL32",
value=HoleValue.GOT,
symbol="_JIT_CONTINUE",
addend=-4,
) as hole
):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These case rewrites are... odd. I don't see how it's better in any way. Is there a setting of some sort that's causing this? Maybe because one case has a guard... but that doesn't seem like a good enough reason to indent every case and wrap them in parens.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case (237-245) doesn't have an if-guard, though. Are all cases put in brackets if any have a guard?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case it might just be due to the line length being shorter than it was previously? Addressing #133123 (review) might fix it

Copy link
Member

@brandtbucher brandtbucher May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure that’s the issue. This uses more horizontal space than not wrapping in parens, due to the additional indent.

I suspect it is because one of the cases has a guard, which feels like a bug.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the wrap-to-80 commit separate (42ce014 (#133123)), and the change was before that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe it has to do with the name assignment to hole?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it seems to be as hole that triggers the brackets. That does seem like a bug?

Copy link
Member

@brandtbucher brandtbucher May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It's not just class patterns, outer grouping symbols in the pattern like (), [], and {} aren't being used effectively. See this playground, where I have my expected formatting going in and the buggy formatting coming out: https://play.ruff.rs/81f62f2d-6858-43eb-8a9b-67dcebdc56f6?secondary=Format

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@brandtbucher brandtbucher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with using ruff, but can you put the line limit back to black's default (I think 88?). A lot of this PR is just line-wrapping churn that sort of hurts readability.

@brandtbucher
Copy link
Member

I'd like to wait on this change until the Ruff issue is fixed.

@AA-Turner
Copy link
Member Author

I'd like to wait on this change until the Ruff issue is fixed.

Happy to, I'll split out the non-JIT changes from this PR.

A

@AA-Turner AA-Turner changed the title Lint: Use Ruff for all formatting in pre-commit Lint: Use Ruff to format Tools/jit May 2, 2025
@AA-Turner AA-Turner marked this pull request as draft May 2, 2025 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants