Skip to content

Commit 4011e6b

Browse files
committed
Use tomllib on Python 3.11
1 parent 19d2760 commit 4011e6b

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ v0.4.0 (in development)
22
-----------------------
33
- Drop support for Python 3.6
44
- Support Python 3.11
5+
- Use `tomllib` on Python 3.11
56

67
v0.3.4 (2022-01-02)
78
-------------------

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ install_requires =
4747
packaging
4848
backports.cached-property; python_version < "3.8"
4949
pydantic ~= 1.7
50-
tomli >= 1.2, < 3.0
50+
tomli >= 1.2, < 3.0; python_version < "3.11"
5151
wheel-filename ~= 1.1
5252

5353
[options.packages.find]

src/check_wheel_contents/config.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
from collections.abc import Sequence
33
from configparser import ConfigParser
44
from pathlib import Path
5+
import sys
56
from typing import Any, List, Optional, Set
67
from pydantic import BaseModel, Field, ValidationError, validator
7-
import tomli
88
from .checks import Check, parse_check_prefix
99
from .errors import UserInputError
1010
from .filetree import Directory
1111
from .util import comma_split
1212

13+
if sys.version_info[:2] >= (3, 11):
14+
from tomllib import load as toml_load
15+
else:
16+
from tomli import load as toml_load
17+
1318
#: The filenames that configuration is read from by default, in descending
1419
#: order of preference
1520
CONFIG_FILES = [
@@ -167,7 +172,7 @@ def from_file(cls, path: Path) -> Optional["Configuration"]:
167172
"""
168173
if path.suffix == ".toml":
169174
with path.open("rb") as fb:
170-
tdata = tomli.load(fb)
175+
tdata = toml_load(fb)
171176
tool = tdata.get("tool")
172177
if not isinstance(tool, dict):
173178
return None

0 commit comments

Comments
 (0)