Skip to content
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

feat: better reload options #362

Merged
merged 12 commits into from
Aug 22, 2024
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,19 @@ Options:
changes (requires granian[reload] extra)
[env var: GRANIAN_RELOAD; default:
(disabled)]
--reload-paths TEXT Paths to watch for changes [env var:
GRANIAN_RELOAD_PATHS; default: Working directory]
--reload-ignore-dirs TEXT Names of directories to ignore changes for
(i.e. should not trigger reload). Extends
the default list of directories to ignore in
watchfiles.filters.DefaultFilter.
[env var: GRANIAN_RELOAD_IGNORE_DIRS]
--reload-ignore-patterns TEXT Entity patterns (regex) to ignore changes for.
--reload-paths PATH Paths to watch for changes [env var:
GRANIAN_RELOAD_PATHS; default: (Working
directory)]
--reload-ignore-dirs TEXT Names of directories to ignore changes for.
Extends the default list of directories to
ignore in watchfiles' default filter [env
var: GRANIAN_RELOAD_IGNORE_DIRS]
--reload-ignore-patterns TEXT Path patterns (regex) to ignore changes for.
Extends the default list of patterns to
ignore in watchfiles.filters.DefaultFilter.
[env var: GRANIAN_RELOAD_IGNORE_ENTITY_PATTERNS]
--reload-ignore-paths TEXT Absolute paths to ignore changes for
[env var: GRANIAN_RELOAD_IGNORE_PATHS]
ignore in watchfiles' default filter [env
var: GRANIAN_RELOAD_IGNORE_PATTERNS]
--reload-ignore-paths PATH Absolute paths to ignore changes for [env
var: GRANIAN_RELOAD_IGNORE_PATHS]
--process-name TEXT Set a custom name for processes (requires
granian[pname] extra) [env var:
GRANIAN_PROCESS_NAME]
Expand Down
8 changes: 4 additions & 4 deletions granian/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,16 @@ def option(*param_decls: str, cls: Optional[Type[click.Option]] = None, **attrs:
@option(
'--reload-ignore-dirs',
help=(
'Names of directories to ignore changes for (i.e. should not trigger reload). '
'Extends the default list of directories to ignore in watchfiles.filters.DefaultFilter.'
'Names of directories to ignore changes for. '
"Extends the default list of directories to ignore in watchfiles' default filter"
),
multiple=True,
)
@option(
'--reload-ignore-patterns',
help=(
'Entity patterns (regex) to ignore changes for. '
'Extends the default list of patterns to ignore in watchfiles.filters.DefaultFilter.'
'Path patterns (regex) to ignore changes for. '
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick note because I stumbled over this while testing the feature.

I had also assumed that this will regex match on the full path of something that triggered the reload. However, this only matches the last part of the path, meaning the exact file/dir that triggered the reload, not the entire path.

https://watchfiles.helpmanual.io/api/filters/#watchfiles.DefaultFilter.ignore_entity_patterns

"Entity" isn't a much better description 😛 but "Path" might be suggesting a different behaviour altogether. WDYT?

I want to avoid issues where users report this to be broken.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I missed that. Would Relative path patterns make sense to you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late answer.

I think being fully explicit could help.

Suggested change
'Path patterns (regex) to ignore changes for. '
'File/directory name patterns (regex) to ignore changes for. '

WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks perfect. Can you open a PR for this? otherwise I'll do it by myself later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, will do!

"Extends the default list of patterns to ignore in watchfiles' default filter"
),
multiple=True,
)
Expand Down
Loading