Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

quality: Specify encoding each time a local file is opened

Clémence Lesnéac47a6d31fc0
diff --git a/helpers/config.py b/helpers/config.py
index 98a2bd9..a6b9c27 100644
--- a/helpers/config.py
+++ b/helpers/config.py
@@ -31,7 +31,11 @@ def load_config() -> RootModel:
if not path:
raise ConfigNotFound(f'Cannot find config file "{config_file}"')
try:
- with open(path, encoding="utf-8") as f:
+ with open(
+ encoding="utf-8",
+ file=path,
+ mode="r",
+ ) as f:
config = RootModel.model_validate(yaml.safe_load(f))
print(f'Config loaded from file "{path}"')
return config
diff --git a/tests/conftest.py b/tests/conftest.py
index ae3d095..25c204c 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -219,7 +219,11 @@ class Conversation(BaseModel):
def with_conversations(fn=None) -> MarkDecorator:
- with open("tests/conversations.yaml", encoding="utf-8") as f:
+ with open(
+ encoding="utf-8",
+ file="tests/conversations.yaml",
+ mode="r",
+ ) as f:
file: dict = yaml.safe_load(f)
conversations: list[Conversation] = []
for conv in file.get("conversations", []):