Skip to content

Struct not tuple for compiled per-file ignores#10864

Merged
carljm merged 2 commits intomainfrom
cjm/structify
Apr 11, 2024
Merged

Struct not tuple for compiled per-file ignores#10864
carljm merged 2 commits intomainfrom
cjm/structify

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
@github-actions
Copy link
Contributor

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 :)

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
Contributor

@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 😁

@carljm carljm merged commit 25f5a8b into main Apr 11, 2024
@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.

4 participants