refactor: tomllib -> tomli

Need to maintain python3.10 compatibility

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2024-11-29 11:32:07 +05:30
parent e2a8c7fed3
commit 722c72a5bf
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F
2 changed files with 5 additions and 5 deletions

View file

@ -25,7 +25,7 @@ import logging
import pkgutil
import unittest
import tomllib
import tomli
import frappe
import frappe.utils.scheduler
@ -91,7 +91,7 @@ def _decorate_all_methods_and_functions_with_type_checker():
def _get_config_from_pyproject(app_path):
try:
with open(f"{app_path}/pyproject.toml", "rb") as f:
config = tomllib.load(f)
config = tomli.load(f)
return (
config.get("tool", {})
.get("frappe", {})
@ -100,7 +100,7 @@ def _decorate_all_methods_and_functions_with_type_checker():
)
except FileNotFoundError:
return {}
except tomllib.TOMLDecodeError:
except tomli.TOMLDecodeError:
logger.warning(f"Failed to parse pyproject.toml for app {app_path}")
return {}

View file

@ -2,7 +2,7 @@ import json
import re
from pathlib import Path
import tomllib
import tomli
import frappe
from frappe import _
@ -58,7 +58,7 @@ def get_pyproject_info(app: str) -> dict:
return {}
with open(pyproject_toml, "rb") as f:
pyproject = tomllib.load(f)
pyproject = tomli.load(f)
return pyproject.get("project", {})