Skip to content

bug(reload exclude dir): Resolve directory path before comparing to path.parents() #2605

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/supervisors/test_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_should_not_reload_when_python_file_in_excluded_subdir_is_changed(self,
config = Config(
app="tests.test_config:asgi_app",
reload=True,
reload_excludes=[str(sub_dir)],
reload_excludes=[str(sub_dir.relative_to(self.reload_path))], # make it relative to current working dir
)
reloader = self._setup_reloader(config)

Expand Down Expand Up @@ -284,7 +284,7 @@ def test_watchfiles_no_changes(self) -> None:
config = Config(
app="tests.test_config:asgi_app",
reload=True,
reload_excludes=[str(sub_dir)],
reload_excludes=[str(sub_dir.relative_to(self.reload_path))], # make it relative to current working dir
)
reloader = self._setup_reloader(config)

Expand Down
1 change: 1 addition & 0 deletions uvicorn/supervisors/watchfilesreload.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self, config: Config):
for e in config.reload_excludes:
p = Path(e)
try:
p = p.resolve()
is_dir = p.is_dir()
except OSError: # pragma: no cover
# gets raised on Windows for values like "*.py"
Expand Down