Feat: do recursive glob matching for ignore_patterns#3539
Merged
georgesittas merged 1 commit intomainfrom Dec 19, 2024
Merged
Conversation
a5a9f87 to
db5fc28
Compare
erindru
approved these changes
Dec 19, 2024
tobymao
reviewed
Dec 19, 2024
db5fc28 to
ed0df51
Compare
georgesittas
commented
Dec 19, 2024
Comment on lines
+266
to
+277
| # We try to match both ignore_pattern itself and every file returned by glob, | ||
| # so that we will always ignore file names that do not appear in the latter. | ||
| ignored_filepaths = set(ignore_patterns) | { | ||
| ignored_path | ||
| for ignore_pattern in ignore_patterns | ||
| for ignored_path in glob.glob(str(self._context.path / ignore_pattern), recursive=True) | ||
| } | ||
| for filepath in path.glob(f"**/*{extension}"): | ||
| for ignore_pattern in ignore_patterns: | ||
| if filepath.match(ignore_pattern): | ||
| break | ||
| else: | ||
| yield filepath | ||
| if any(filepath.match(ignored_filepath) for ignored_filepath in ignored_filepaths): | ||
| continue | ||
|
|
||
| yield filepath |
Collaborator
Author
There was a problem hiding this comment.
Refactored to pre-compute the set of ignored file paths. See other thread re: performance implications.
tobymao
approved these changes
Dec 19, 2024
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.
Fixes #3507