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

fix: read/write encoding for open(...) is now utf-8 #29

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion horde_worker_regen/bridge_data/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
4 changes: 2 additions & 2 deletions horde_worker_regen/bridge_data/load_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ 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)
if bridge_data is not None:
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)
Expand Down
2 changes: 1 addition & 1 deletion load_env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bridge_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down