1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
--- a/lib/ts_utils/metadata.py
+++ b/lib/ts_utils/metadata.py
@@ -13,7 +13,11 @@
from typing import Final, NamedTuple, final
from typing_extensions import Annotated, TypeGuard
-import tomli
+try:
+ import tomllib
+except ImportError:
+ import tomli as tomllib
+
import tomlkit
from packaging.requirements import Requirement
from packaging.specifiers import Specifier
@@ -45,7 +49,7 @@
@cache
def _get_oldest_supported_python() -> str:
with PYPROJECT_PATH.open("rb") as config:
- val = tomli.load(config)["tool"]["typeshed"]["oldest_supported_python"]
+ val = tomllib.load(config)["tool"]["typeshed"]["oldest_supported_python"]
assert type(val) is str
return val
@@ -83,7 +87,7 @@
def read_stubtest_settings(distribution: str) -> StubtestSettings:
"""Return an object describing the stubtest settings for a single stubs distribution."""
with metadata_path(distribution).open("rb") as f:
- data: dict[str, object] = tomli.load(f).get("tool", {}).get("stubtest", {})
+ data: dict[str, object] = tomllib.load(f).get("tool", {}).get("stubtest", {})
skip: object = data.get("skip", False)
apt_dependencies: object = data.get("apt_dependencies", [])
@@ -198,7 +202,7 @@
"""
try:
with metadata_path(distribution).open("rb") as f:
- data: dict[str, object] = tomli.load(f)
+ data: dict[str, object] = tomllib.load(f)
except FileNotFoundError:
raise NoSuchStubError(f"Typeshed has no stubs for {distribution!r}!") from None
--- a/tests/mypy_test.py
+++ b/tests/mypy_test.py
@@ -19,7 +19,7 @@
from typing import Any, NamedTuple
from typing_extensions import Annotated, TypeAlias
-import tomli
+import tomllib as tomli
from packaging.requirements import Requirement
from ts_utils.metadata import PackageDependencies, get_recursive_requirements, metadata_path, read_metadata
--- a/stub-uploader/requirements.txt
+++ b/stub-uploader/requirements.txt
@@ -1,7 +1,6 @@
# scripts
packaging
requests < 2.30.0
-tomli
# build and upload
build
--- a/stub-uploader/stub_uploader/metadata.py
+++ b/stub-uploader/stub_uploader/metadata.py
@@ -13,7 +13,7 @@
from typing import Any, Optional
import requests
-import tomli
+import tomllib as tomli
from packaging.requirements import Requirement
from packaging.specifiers import Specifier, InvalidSpecifier
--- a/stub-uploader/stub_uploader/ts_data.py
+++ b/stub-uploader/stub_uploader/ts_data.py
@@ -13,7 +13,7 @@
from packaging.requirements import Requirement
from packaging.version import Version
-from tomli import load as toml_load
+from tomllib import load as toml_load
REQUIREMENTS = "requirements-tests.txt"
PYPROJECT = "pyproject.toml"
|