|
8 | 8 | import datetime |
9 | 9 | import functools |
10 | 10 | import re |
| 11 | +import sys |
11 | 12 | import urllib.parse |
12 | 13 | from collections.abc import Mapping |
13 | 14 | from dataclasses import dataclass |
14 | 15 | from pathlib import Path |
15 | 16 | from typing import Annotated, Any, Final, NamedTuple, final |
16 | 17 | from typing_extensions import TypeGuard |
17 | 18 |
|
18 | | -import tomli |
| 19 | +if sys.version_info >= (3, 11): |
| 20 | + import tomllib |
| 21 | +else: |
| 22 | + import tomli as tomllib |
| 23 | + |
19 | 24 | import tomlkit |
20 | 25 | from packaging.requirements import Requirement |
21 | 26 | from packaging.specifiers import Specifier |
@@ -52,7 +57,7 @@ def _is_nested_dict(obj: object) -> TypeGuard[dict[str, dict[str, Any]]]: |
52 | 57 | @functools.cache |
53 | 58 | def get_oldest_supported_python() -> str: |
54 | 59 | with PYPROJECT_PATH.open("rb") as config: |
55 | | - val = tomli.load(config)["tool"]["typeshed"]["oldest_supported_python"] |
| 60 | + val = tomllib.load(config)["tool"]["typeshed"]["oldest_supported_python"] |
56 | 61 | assert type(val) is str |
57 | 62 | return val |
58 | 63 |
|
@@ -92,7 +97,7 @@ def system_requirements_for_platform(self, platform: str) -> list[str]: |
92 | 97 | def read_stubtest_settings(distribution: str) -> StubtestSettings: |
93 | 98 | """Return an object describing the stubtest settings for a single stubs distribution.""" |
94 | 99 | with metadata_path(distribution).open("rb") as f: |
95 | | - data: dict[str, object] = tomli.load(f).get("tool", {}).get("stubtest", {}) |
| 100 | + data: dict[str, object] = tomllib.load(f).get("tool", {}).get("stubtest", {}) |
96 | 101 |
|
97 | 102 | skip: object = data.get("skip", False) |
98 | 103 | apt_dependencies: object = data.get("apt_dependencies", []) |
|
0 commit comments