fix: Fix auto-reload with globs in IGNORE_FILES (#3441)

The default `IGNORE_FILES` value of `'.*'` was being compiled to a regular expression and then passed into `watchfiles.DefaultFilter` to filter out files when auto-reload 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.
This commit is contained in:
Yashas Lokesh 2025-01-15 11:40:27 -05:00 committed by GitHub
commit 543424aa41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 96 additions and 9 deletions

View file

@ -150,13 +150,17 @@ Basic settings
READERS = {'foo': FooReader}
.. data:: IGNORE_FILES = ['.*']
.. data:: IGNORE_FILES = ['**/.*']
A list of glob patterns. Files and directories matching any of these patterns
will be ignored by the processor. For example, the default ``['.*']`` will
A list of Unix glob patterns. Files and directories matching any of these patterns
or any of the commonly hidden files and directories set by ``watchfiles.DefaultFilter``
will be ignored by the processor. For example, the default ``['**/.*']`` will
ignore "hidden" files and directories, and ``['__pycache__']`` would ignore
Python 3's bytecode caches.
For a full list of the commonly hidden files set by ``watchfiles.DefaultFilter``,
please refer to the `watchfiles documentation`_.
.. data:: MARKDOWN = {...}
Extra configuration settings for the Markdown processor. Refer to the Python
@ -1423,3 +1427,4 @@ Example settings
.. _Jinja Environment documentation: https://jinja.palletsprojects.com/en/latest/api/#jinja2.Environment
.. _Docutils Configuration: http://docutils.sourceforge.net/docs/user/config.html
.. _`watchfiles documentation`: https://watchfiles.helpmanual.io/api/filters/#watchfiles.DefaultFilter.ignore_dirs