Skip to content

Commit e942b12

Browse files
committed
Support TOML v1.0.0 syntax in pyproject.toml
1 parent 8347b59 commit e942b12

File tree

6 files changed

+8
-4
lines changed

6 files changed

+8
-4
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ repos:
5858
- py>=1.8.2
5959
- attrs>=19.2.0
6060
- packaging
61-
- types-toml
61+
- tomli
6262
- types-pkg_resources
6363
- repo: local
6464
hooks:

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ Sven-Hendrik Haase
302302
Sylvain Marié
303303
Tadek Teleżyński
304304
Takafumi Arakaki
305+
Taneli Hukkinen
305306
Tanvi Mehta
306307
Tarcisio Fischer
307308
Tareq Alayan

changelog/8789.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Support TOML v1.0.0 syntax in ``pyproject.toml``.

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
pluggy>=0.12,<1.0.0a1
4949
py>=1.8.2
50-
toml
50+
tomli>=1.0.0,<2.0.0
5151
atomicwrites>=1.0;sys_platform=="win32"
5252
colorama;sys_platform=="win32"
5353
importlib-metadata>=0.12;python_version<"3.8"

src/_pytest/config/findpaths.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ def load_config_dict_from_file(
6464

6565
# '.toml' files are considered if they contain a [tool.pytest.ini_options] table.
6666
elif filepath.suffix == ".toml":
67-
import toml
67+
import tomli
6868

69-
config = toml.load(str(filepath))
69+
config = tomli.loads(filepath.read_text(encoding="utf-8"))
7070

7171
result = config.get("tool", {}).get("pytest", {}).get("ini_options", None)
7272
if result is not None:

testing/test_findpaths.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def test_valid_toml_file(self, tmp_path: Path) -> None:
7777
y = 20.0
7878
values = ["tests", "integration"]
7979
name = "foo"
80+
heterogeneous_array = [1, "str"]
8081
"""
8182
),
8283
encoding="utf-8",
@@ -86,6 +87,7 @@ def test_valid_toml_file(self, tmp_path: Path) -> None:
8687
"y": "20.0",
8788
"values": ["tests", "integration"],
8889
"name": "foo",
90+
"heterogeneous_array": [1, "str"],
8991
}
9092

9193

0 commit comments

Comments
 (0)