refactor: tomli -> tomllib
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
parent
4c871f1c09
commit
588cb1e44d
4 changed files with 8 additions and 11 deletions
|
|
@ -23,10 +23,9 @@ import functools
|
|||
import inspect
|
||||
import logging
|
||||
import pkgutil
|
||||
import tomllib
|
||||
import unittest
|
||||
|
||||
import tomli
|
||||
|
||||
import frappe
|
||||
import frappe.utils.scheduler
|
||||
from frappe.tests.utils import make_test_records, toggle_test_mode
|
||||
|
|
@ -91,7 +90,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 = tomli.load(f)
|
||||
config = tomllib.load(f)
|
||||
return (
|
||||
config.get("tool", {})
|
||||
.get("frappe", {})
|
||||
|
|
@ -100,7 +99,7 @@ def _decorate_all_methods_and_functions_with_type_checker():
|
|||
)
|
||||
except FileNotFoundError:
|
||||
return {}
|
||||
except tomli.TOMLDecodeError:
|
||||
except tomllib.TOMLDecodeError:
|
||||
logger.warning(f"Failed to parse pyproject.toml for app {app_path}")
|
||||
return {}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import datetime
|
|||
import json
|
||||
import logging
|
||||
import os
|
||||
import tomllib
|
||||
from collections import defaultdict
|
||||
from collections.abc import Generator
|
||||
from functools import cache
|
||||
|
|
@ -10,8 +11,6 @@ from pathlib import Path
|
|||
from types import MappingProxyType, ModuleType
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
import tomli
|
||||
|
||||
import frappe
|
||||
from frappe.model.naming import revert_series_if_last
|
||||
from frappe.modules import get_doctype_module, get_module_path, load_doctype_module
|
||||
|
|
@ -129,7 +128,7 @@ def load_test_records_for(index_doctype) -> dict[str, Any]:
|
|||
toml_path = os.path.join(module_path, "test_records.toml")
|
||||
if os.path.exists(toml_path):
|
||||
with open(toml_path, "rb") as f:
|
||||
return tomli.load(f)
|
||||
return tomllib.load(f)
|
||||
|
||||
else:
|
||||
return {}
|
||||
|
|
|
|||
|
|
@ -394,7 +394,7 @@ def show_update_popup():
|
|||
|
||||
|
||||
def get_pyproject(app: str) -> dict | None:
|
||||
from tomli import load
|
||||
from tomllib import load
|
||||
|
||||
pyproject_path = frappe.get_app_path(app, "..", "pyproject.toml")
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@ import contextlib
|
|||
import importlib.metadata
|
||||
import json
|
||||
import re
|
||||
import tomllib
|
||||
from pathlib import Path
|
||||
|
||||
import tomli
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.permissions import is_system_user
|
||||
|
|
@ -134,7 +133,7 @@ def get_pyproject_info(app: str) -> dict:
|
|||
return {}
|
||||
|
||||
with open(pyproject_toml, "rb") as f:
|
||||
pyproject = tomli.load(f)
|
||||
pyproject = tomllib.load(f)
|
||||
|
||||
return pyproject.get("project", {})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue