Fix docs and add overlap test for negated per-file-ignores #10863
Merged
Fix docs and add overlap test for negated per-file-ignores #10863
Conversation
BurntSushi
reviewed
Apr 10, 2024
Contributor
|
Closed
Co-authored-by: Alex Waygood <Alex.Waygood@gmail.com>
This reverts commit 1bc4610.
Contributor
Author
|
Going to go ahead and merge this without further review; we should get the doc fix out, and this is just a minor doc fix and a test that passes. This doesn't preclude revisiting the behavior of negated patterns, but that can be another PR. |
Member
charliermarsh
left a comment
There was a problem hiding this comment.
👍 Good call, sorry for the delay.
Glyphack
pushed a commit
to Glyphack/ruff
that referenced
this pull request
Apr 12, 2024
…#10863) Refs astral-sh#3172 ## Summary Fix a typo in the docs example, and add a test for the case where a negative pattern and a positive pattern overlap. The behavior here is simple: patterns (positive or negative) are always additive if they hit (i.e. match for a positive pattern, don't match for a negated pattern). We never "un-ignore" previously-ignored rules based on a pattern (positive or negative) failing to hit. It's simple enough that I don't really see other cases we need to add tests for (the tests we have cover all branches in the ignores_from_path function that implements the core logic), but open to reviewer feedback. I also didn't end up changing the docs to explain this more, because I think they are accurate as written and don't wrongly imply any more complex behavior. Open to reviewer feedback on this as well! After some discussion, I think allowing negative patterns to un-ignore rules is too confusing and easy to get wrong; if we need that, we should add `per-file-selects` instead. ## Test Plan Test/docs only change; tests pass, docs render and look right. --------- Co-authored-by: Alex Waygood <Alex.Waygood@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #3172
Summary
Fix a typo in the docs example, and add a test for the case where a negative pattern and a positive pattern overlap.
The behavior here is simple: patterns (positive or negative) are always additive if they hit (i.e. match for a positive pattern, don't match for a negated pattern). We never "un-ignore" previously-ignored rules based on a pattern (positive or negative) failing to hit.
It's simple enough that I don't really see other cases we need to add tests for (the tests we have cover all branches in the ignores_from_path function that implements the core logic), but open to reviewer feedback.
I also didn't end up changing the docs to explain this more, because I think they are accurate as written and don't wrongly imply any more complex behavior. Open to reviewer feedback on this as well!
After some discussion, I think allowing negative patterns to un-ignore rules is too confusing and easy to get wrong; if we need that, we should add
per-file-selectsinstead.Test Plan
Test/docs only change; tests pass, docs render and look right.