From f88389fb418a408d6e244a9c36d5603a57db701b Mon Sep 17 00:00:00 2001 From: tazlin Date: Mon, 23 Oct 2023 10:25:36 -0400 Subject: [PATCH] fix: read/write encoding for `open(...)` is now `utf-8` --- horde_worker_regen/bridge_data/data_model.py | 2 +- horde_worker_regen/bridge_data/load_config.py | 4 ++-- load_env_vars.py | 2 +- tests/test_bridge_data.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/horde_worker_regen/bridge_data/data_model.py b/horde_worker_regen/bridge_data/data_model.py index b8ef8597..ccf4f4ba 100644 --- a/horde_worker_regen/bridge_data/data_model.py +++ b/horde_worker_regen/bridge_data/data_model.py @@ -56,7 +56,7 @@ def save(self, file_path: str) -> None: if self._yaml_loader is None: self._yaml_loader = YAML() - with open(file_path, "w") as f: + with open(file_path, "w", encoding="utf-8") as f: self._yaml_loader.dump(self.model_dump(), f) diff --git a/horde_worker_regen/bridge_data/load_config.py b/horde_worker_regen/bridge_data/load_config.py index 5d5779e2..49858854 100644 --- a/horde_worker_regen/bridge_data/load_config.py +++ b/horde_worker_regen/bridge_data/load_config.py @@ -79,7 +79,7 @@ def load( if file_format == ConfigFormat.yaml: yaml = YAML() - with open(file_path) as f: + with open(file_path, encoding="utf-8") as f: config = yaml.load(f) bridge_data = reGenBridgeData.model_validate(config) @@ -87,7 +87,7 @@ def load( bridge_data._yaml_loader = yaml if file_format == ConfigFormat.json: - with open(file_path) as f: + with open(file_path, encoding="utf-8") as f: config = json.load(f) bridge_data = reGenBridgeData.model_validate(config) diff --git a/load_env_vars.py b/load_env_vars.py index 5fc9799f..3814d072 100644 --- a/load_env_vars.py +++ b/load_env_vars.py @@ -13,7 +13,7 @@ def load_env_vars() -> None: if not pathlib.Path("bridgeData.yaml").exists(): raise FileNotFoundError("bridgeData.yaml not found") - with open("bridgeData.yaml") as f: + with open("bridgeData.yaml", encoding="utf-8") as f: config = yaml.load(f) if "cache_home" in config: diff --git a/tests/test_bridge_data.py b/tests/test_bridge_data.py index 42c2c6a7..bcd262ba 100644 --- a/tests/test_bridge_data.py +++ b/tests/test_bridge_data.py @@ -14,7 +14,7 @@ def test_bridge_data_yaml() -> None: yaml = YAML(typ="safe") - with open(bridge_data_filename) as f: + with open(bridge_data_filename, encoding="utf-8") as f: bridge_data_raw = yaml.load(f) assert bridge_data_raw is not None