Tree: Switch to Pydantic 2

Pydantic 2 has more modern methods and stability compared to Pydantic 1

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri
2023-12-17 01:06:10 -05:00
committed by Brian Dashore
parent f631dd6ff7
commit 51ca1ff396
8 changed files with 18 additions and 15 deletions

View File

@@ -30,7 +30,7 @@ def load_auth_keys():
try:
with open("api_tokens.yml", "r", encoding = 'utf8') as auth_file:
auth_keys_dict = yaml.safe_load(auth_file)
auth_keys = AuthKeys.parse_obj(auth_keys_dict)
auth_keys = AuthKeys.model_validate(auth_keys_dict)
except Exception as _:
new_auth_keys = AuthKeys(
api_key = secrets.token_hex(16),
@@ -39,7 +39,7 @@ def load_auth_keys():
auth_keys = new_auth_keys
with open("api_tokens.yml", "w", encoding = "utf8") as auth_file:
yaml.safe_dump(auth_keys.dict(), auth_file, default_flow_style=False)
yaml.safe_dump(auth_keys.model_dump(), auth_file, default_flow_style=False)
print(
f"Your API key is: {auth_keys.api_key}\n"