-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix: Fix auto-reload with globs in IGNORE_FILES
#3441
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love that this has unit tests, which give a concrete idea of what the behavior should be.
I don't love that the behavior seems a bit hard for me to understand, though it could just be me.
self.ignore_file_patterns = ignore_file_patterns | ||
|
||
def __call__(self, change: watchfiles.Change, path: str) -> bool: | ||
return super().__call__(change, path) and not any( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this logic. Is it something like:
"Ignore the file if it regex-matches any pattern in ignore_file_patterns, unless the basename of the file also fn-matches any pattern in ignore_file_patterns"?
That seems quite subtle to me, i.e. a bit hard to understand.
I could be wrong, though, and it's not obvious to me what the simple solution is.
ah, I can add more comments describing the purpose of the filter class and how it's used with the watchfiles functions For a brief summary for you, The filter class is setup to return The design for the |
Thanks for your reply. Sounds like "just match with unix globs instead of regexes", which is pretty easy to understand and use. If that's true, then great. Sorry I am slow, but why call
I don't think I asked about this?, but anyway I was pretty happy with the unit tests. |
I'm doing the super call to leave in the sensible defaults set by I was debating whether to keep the super call and just use
Sorry, was elaborating to get ahead of possible questions or concerns from other contributors 😊 |
This all sounds reasonable to me. I would put it in code comments, as you suggested, and docs, so a casual reader knows what's going on. They both should say that the format is "unix glob" format plus commonly hidden files (with a link to the default for filewatcher). |
@yashaslokesh: Any chance you could add the comments @boxydog mentioned? I agree that would help make things clearer, and I would like to release a new version of Pelican in a day or two if possible. |
hi! yes, sorry, got sidetracked at work for a few days. I found a way to improve my implementation as well, I will try to get these new changes with the comments out today |
…h Unix shell wildcards The default `IGNORE_FILES` value of `'.*'` was being compiled to a regular expression and then passed into `watchfiles.DefaultFilter` to filter out files when autoreload is enabled. This commit compares the patterns from `IGNORE_FILES` directly with the filename to match the usage of `fnmatch` elsewhere in the codebase. The new filtering class will continue working as expected for custom `IGNORE_FILES` settings.
73279f1
to
c444c88
Compare
@justinmayer Fixed the My previous changes compared the |
I confirm that the new |
The test failures shown here are almost certainly not related to this pull request. I am currently investigating, but the cause is likely related to some dependency change and/or the Typogrify-related changes @davidlesieur and I have been collaborating on. |
Regarding the aforementioned test failures, I should have known… Pygments strikes again: #3446 |
IGNORE_FILES
The default
IGNORE_FILES
value of'.*'
was being compiled to a regular expression and then passed intowatchfiles.DefaultFilter
to filter out files when autoreload is enabled.This commit compares the patterns from
IGNORE_FILES
directly with the filename to match the usage offnmatch
elsewhere in the codebase. The new filtering class will continue working as expected for customIGNORE_FILES
settings.Pull Request Checklist
Resolves: #3431
I didn't update any documentation because the current instructions forIGNORE_FILES
are correct, this setting is still expected to be a list of glob patterns.Edit: January 14th - Wrote documentation to further explain the
IGNORE_FILES
setting and the new default valueAlso tested locally in addition to adding unit tests, both with the default settings and with
IGNORE_FILES = ['*.md']