🐛 fix: load config file in `UTF-8` (#456)

Co-authored-by: Nyakku Shigure <sigure.qaq@gmail.com>
This commit is contained in:
XDcedar 2025-03-07 15:06:30 +08:00 committed by GitHub
parent c55528920f
commit 63153cae3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -34,7 +34,9 @@ DOWNLOAD_RESOURCE_TYPES: list[DownloadResourceType] = [
def parse_config_path() -> Path | None:
pre_parser = argparse.ArgumentParser(description="yutto pre parser", add_help=False)
pre_parser.add_argument("--config", type=path_from_cli, default=search_for_settings_file(), help="配置文件路径")
pre_parser.add_argument(
"--config", type=path_from_cli, default=search_for_settings_file(), help="配置文件路径UTF-8 格式)"
)
args, _ = pre_parser.parse_known_args()
return args.config

View File

@ -114,7 +114,7 @@ def search_for_settings_file() -> Path | None:
def load_settings_file(settings_file: Path) -> YuttoSettings:
with settings_file.open("r") as f:
with settings_file.open("r", encoding="utf-8") as f:
settings_raw: Any = tomllib.loads(f.read()) # pyright: ignore[reportUnknownMemberType]
return YuttoSettings.model_validate(settings_raw)