Skip to content

Commit d27685b

Browse files
hroncokcsernazs
authored andcommitted
Where available, use tomllib from the standard library
Fallback to tomli, which is the same project, rather than toml which wasn't updated for a while.
1 parent f669ff8 commit d27685b

File tree

3 files changed

+12
-30
lines changed

3 files changed

+12
-30
lines changed

poetry.lock

Lines changed: 1 addition & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ types-requests = "*"
4747
pytest = ">=7.1.3,<9.0.0"
4848
pytest-cov = ">=3,<6"
4949
coverage = ">=6.4.4,<8.0.0"
50-
types-toml = "*"
51-
toml = "^0.10.2"
50+
tomli = { version = "*", markers = "python_version < '3.11'"}
5251
black = "*"
5352
ruff = "*"
5453
mypy = "*"
@@ -72,8 +71,7 @@ coverage = "*"
7271
requests = "*"
7372
types-requests = "*"
7473
pre-commit = "*"
75-
types-toml = "*"
76-
toml = "*"
74+
tomli = { version = "*", markers = "python_version < '3.11'"}
7775
mypy = "*"
7876

7977
[build-system]

tests/test_release.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
from typing import Iterable
1212

1313
import pytest
14-
import toml
14+
15+
try:
16+
import tomllib
17+
except ImportError:
18+
# Unfortunately mypy cannot handle this try/expect pattern, and "type: ignore"
19+
# is the simplest work-around. See: https://github.com/python/mypy/issues/1153
20+
import tomli as tomllib # type: ignore
1521

1622
# TODO: skip if poetry is not available or add mark to test it explicitly
1723

@@ -31,8 +37,8 @@ def pyproject_path() -> Path:
3137
@pytest.fixture(scope="session")
3238
def pyproject(pyproject_path: Path):
3339
assert pyproject_path.is_file()
34-
with pyproject_path.open() as infile:
35-
pyproject = toml.load(infile)
40+
with pyproject_path.open("rb") as infile:
41+
pyproject = tomllib.load(infile)
3642
return pyproject
3743

3844

0 commit comments

Comments
 (0)