From 3452880b1681a3b2cd66db508131a1dcbc2f1199 Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Thu, 30 Sep 2021 01:22:12 +0800 Subject: [PATCH] :alembic: add fastapi reload include/exclude --- docs/api/drivers/fastapi.md | 30 ++++++++++++++++++++++++++++++ nonebot/drivers/fastapi.py | 22 ++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/docs/api/drivers/fastapi.md b/docs/api/drivers/fastapi.md index c6d3940a..e28dc8b2 100644 --- a/docs/api/drivers/fastapi.md +++ b/docs/api/drivers/fastapi.md @@ -109,6 +109,36 @@ FastAPI 驱动框架设置,详情参考 FastAPI 文档 +### `fastapi_reload_includes` + + +* **类型** + + `List[str]` + + + +* **说明** + + 要监听的文件列表,支持 glob pattern,默认为 uvicorn 默认值 + + + +### `fastapi_reload_excludes` + + +* **类型** + + `List[str]` + + + +* **说明** + + 不要监听的文件列表,支持 glob pattern,默认为 uvicorn 默认值 + + + ## _class_ `Driver` 基类:[`nonebot.drivers.ReverseDriver`](README.md#nonebot.drivers.ReverseDriver), [`nonebot.drivers.ForwardDriver`](README.md#nonebot.drivers.ForwardDriver) diff --git a/nonebot/drivers/fastapi.py b/nonebot/drivers/fastapi.py index aaa5a0fd..5c88f333 100644 --- a/nonebot/drivers/fastapi.py +++ b/nonebot/drivers/fastapi.py @@ -104,6 +104,26 @@ class Config(BaseSettings): 重载延迟,默认为 uvicorn 默认值 """ + fastapi_reload_includes: List[str] = [] + """ + :类型: + + ``List[str]`` + + :说明: + + 要监听的文件列表,支持 glob pattern,默认为 uvicorn 默认值 + """ + fastapi_reload_excludes: List[str] = [] + """ + :类型: + + ``List[str]`` + + :说明: + + 不要监听的文件列表,支持 glob pattern,默认为 uvicorn 默认值 + """ class Config: extra = "ignore" @@ -241,6 +261,8 @@ class Driver(ReverseDriver, ForwardDriver): (bool(app) and self.config.debug), reload_dirs=self.fastapi_config.fastapi_reload_dirs or None, reload_delay=self.fastapi_config.fastapi_reload_delay, + reload_includes=self.fastapi_config.fastapi_reload_includes or None, + reload_excludes=self.fastapi_config.fastapi_reload_excludes or None, debug=self.config.debug, log_config=LOGGING_CONFIG, **kwargs)