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: support passing watchfiles.BaseFilter instance #437

Open
monosans opened this issue Nov 21, 2024 · 2 comments
Open

feat: support passing watchfiles.BaseFilter instance #437

monosans opened this issue Nov 21, 2024 · 2 comments

Comments

@monosans
Copy link
Contributor

I think the user should be able to create their own reload filter and pass it this way. The current way of customizing reload filters is very limited, while this way removes all limitations.

import watchfiles
from granian import Granian

reload_filter_instance = watchfiles.PythonFilter(extra_extensions=(".html",))
# Let's call it reload_filter_instance to avoid making breaking changes
Granian(..., reload_filter_instance=reload_filter_instance).serve()

I am willing to submit a PR if you approve this change.

@monosans
Copy link
Contributor Author

For CLI users, we can add the ability to pass the path to the instance by --reload-filter-instance some_package.some_module:my_reload_filter.

@gi0baro
Copy link
Member

gi0baro commented Nov 26, 2024

Sounds good to me in regards of the Python interface, but for the CLI maybe an alternative approach could be to add the --reload-only-* counterparts of the existing --reload-ignore-* params?
At that point the usage would be smth like --reload-only-patterns *.py --reload-only-patterns *.html..

WDYT @monosans?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants