Skip to content

Commit 392c81d

Browse files
authored
Switch from toml to tomli (#6023)
1 parent 7d41e67 commit 392c81d

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v2
1919
- uses: actions/setup-python@v2
20-
- run: pip install toml
20+
- run: pip install $(grep tomli== requirements-tests-py3.txt)
2121
- run: ./tests/check_consistent.py
2222

2323
pep-604:
@@ -77,7 +77,7 @@ jobs:
7777
steps:
7878
- uses: actions/checkout@v2
7979
- uses: actions/setup-python@v2
80-
- run: pip install $(grep mypy== requirements-tests-py3.txt)
80+
- run: pip install $(grep tomli== requirements-tests-py3.txt) $(grep mypy== requirements-tests-py3.txt)
8181
- run: ./tests/mypy_test.py --platform=${{ matrix.platform }} --python-version=${{ matrix.python-version }}
8282

8383
pyright:
@@ -125,7 +125,7 @@ jobs:
125125
- name: Update pip
126126
run: python -m pip install -U pip
127127
- name: Install dependencies
128-
run: pip install $(grep mypy== requirements-tests-py3.txt)
128+
run: pip install $(grep tomli== requirements-tests-py3.txt) $(grep mypy== requirements-tests-py3.txt)
129129
- name: Run stubtest
130130
run: python tests/stubtest_stdlib.py --ignore-unused-allowlist
131131

@@ -142,6 +142,6 @@ jobs:
142142
with:
143143
python-version: 3.9
144144
- name: Install dependencies
145-
run: pip install toml
145+
run: pip install $(grep tomli== requirements-tests-py3.txt)
146146
- name: Run stubtest
147147
run: python tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }}

requirements-tests-py3.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ flake8-bugbear==21.4.3
66
flake8-pyi==20.10.0
77
isort==5.9.3
88
pytype==2021.08.11
9+
tomli==1.1.0

tests/check_consistent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import os
1616
import re
1717

18-
import toml
18+
import tomli
1919

2020
consistent_files = [
2121
{"stdlib/@python2/builtins.pyi", "stdlib/@python2/__builtin__.pyi"},
@@ -165,7 +165,7 @@ def _strip_dep_version(dependency):
165165
def check_metadata():
166166
for distribution in os.listdir("stubs"):
167167
with open(os.path.join("stubs", distribution, "METADATA.toml")) as f:
168-
data = toml.loads(f.read())
168+
data = tomli.loads(f.read())
169169
assert "version" in data, f"Missing version for {distribution}"
170170
version = data["version"]
171171
msg = f"Unsupported Python version {version}"

tests/mypy_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from pathlib import Path
2222
from typing import Dict, NamedTuple
2323

24-
import toml
24+
import tomli
2525

2626
parser = argparse.ArgumentParser(description="Test runner for typeshed. Patterns are unanchored regexps on the full path.")
2727
parser.add_argument("-v", "--verbose", action="count", default=0, help="More output")
@@ -101,7 +101,7 @@ def parse_version(v_str):
101101
def is_supported(distribution, major):
102102
dist_path = Path("stubs", distribution)
103103
with open(dist_path / "METADATA.toml") as f:
104-
data = dict(toml.loads(f.read()))
104+
data = dict(tomli.loads(f.read()))
105105
if major == 2:
106106
# Python 2 is not supported by default.
107107
return bool(data.get("python2", False)) or (dist_path / "@python2").exists()
@@ -154,7 +154,7 @@ def add_configuration(configurations, seen_dist_configs, distribution):
154154
return
155155

156156
with open(os.path.join("stubs", distribution, "METADATA.toml")) as f:
157-
data = dict(toml.loads(f.read()))
157+
data = dict(tomli.loads(f.read()))
158158

159159
mypy_tests_conf = data.get("mypy-tests")
160160
if not mypy_tests_conf:

tests/stubtest_third_party.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import subprocess
77
import sys
88
import tempfile
9-
import toml
9+
import tomli
1010
import venv
1111
from glob import glob
1212
from pathlib import Path
@@ -34,7 +34,7 @@ def get_mypy_req():
3434

3535
def run_stubtest(dist: Path) -> None:
3636
with open(dist / "METADATA.toml") as f:
37-
metadata = dict(toml.loads(f.read()))
37+
metadata = dict(tomli.loads(f.read()))
3838

3939
# Ignore stubs that don't support Python 3
4040
if not has_py3_stubs(dist):

0 commit comments

Comments
 (0)