granian
granian copied to clipboard
Make the watchfiles dependency optional
trafficstars
Granian depends on the watchfiles Python package for the --reload (reload on file changes) feature. This feature is helpful for local development, but is not needed on production (at least that I know of!).
The watchfiles package brings in the following extra packages to the granian dependency closure:
- watchfiles
- anyio
- idna
- sniffio
- anyio
To reduce the dependencies in production, I propose making watchfiles optional:
- Move the watchfiles import to be done lazily in
_serve_with_reloader. - Remove the
watchfilesfrom the defaultdependenciesand move it to agranian[watch]extra instead. - Update the docs to mention that the
[watch]extra is needed for--reloadto work.
I can implement this if it sounds good.
Sounds reasonable to me, I'll be happy to accept a PR for this.
The only thing I would change in your plan is to name the extra reload instead of watch just to be more consistent.