Skip to content
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

Struct not tuple for compiled per-file ignores #10864

Merged
merged 2 commits into from Apr 11, 2024
Merged

Struct not tuple for compiled per-file ignores #10864

merged 2 commits into from Apr 11, 2024

Conversation

carljm
Copy link
Contributor

@carljm carljm commented Apr 10, 2024

Summary

Code cleanup for per-file ignores; use a struct instead of a tuple.

Named the structs for individual ignores and the list of ignores CompiledPerFileIgnore and CompiledPerFileIgnoreList. Name choice is because we already have a PerFileIgnore struct for a pre-compiled-matchers form of the config. Name bikeshedding welcome.

Test Plan

Refactor, should not change behavior; existing tests pass.

@carljm carljm added the internal An internal refactor or improvement label Apr 10, 2024
Copy link

github-actions bot commented Apr 10, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

I like it :)

crates/ruff_linter/src/settings/types.rs Outdated Show resolved Hide resolved
Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

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

LGTM!

Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
@carljm
Copy link
Contributor Author

carljm commented Apr 11, 2024

@MichaReiser @snowsignal requesting another review because I would like to make sure that the change we made to display_settings! (to give it capability to display a GlobMatcher reasonably) looks OK.

The previous Display implementation here was actually pretty useless, it used {:#?} for a GlobMatcher which gives a massive output with all the internal structure of the GlobMatcher; suitable for debugging a GlobMatcher but not suitable for Display of the per-file-ignore settings at all. Given that nobody noticed that, I'm guessing we may never really use Display on these anywhere?

But anyway, the new version here is much better / more readable (for Display purposes), it just shows the actual file pattern of the GlobMatcher.

Copy link
Member

@snowsignal snowsignal left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thank you 😁

crates/ruff_linter/src/settings/mod.rs Show resolved Hide resolved
@carljm carljm merged commit 25f5a8b into main Apr 11, 2024
17 checks passed
@carljm carljm deleted the cjm/structify branch April 11, 2024 19:47
Glyphack pushed a commit to Glyphack/ruff that referenced this pull request Apr 12, 2024
## Summary

Code cleanup for per-file ignores; use a struct instead of a tuple.

Named the structs for individual ignores and the list of ignores
`CompiledPerFileIgnore` and `CompiledPerFileIgnoreList`. Name choice is
because we already have a `PerFileIgnore` struct for a
pre-compiled-matchers form of the config. Name bikeshedding welcome.

## Test Plan

Refactor, should not change behavior; existing tests pass.

---------

Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An internal refactor or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants