Skip to content

Switches from toml to tomli #6023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: pip install toml
- run: pip install $(grep tomli== requirements-tests-py3.txt)
- run: ./tests/check_consistent.py

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

pyright:
Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:
- name: Update pip
run: python -m pip install -U pip
- name: Install dependencies
run: pip install $(grep mypy== requirements-tests-py3.txt)
run: pip install $(grep tomli== requirements-tests-py3.txt) $(grep mypy== requirements-tests-py3.txt)
- name: Run stubtest
run: python tests/stubtest_stdlib.py --ignore-unused-allowlist

Expand All @@ -142,6 +142,6 @@ jobs:
with:
python-version: 3.9
- name: Install dependencies
run: pip install toml
run: pip install $(grep tomli== requirements-tests-py3.txt)
- name: Run stubtest
run: python tests/stubtest_third_party.py --num-shards 4 --shard-index ${{ matrix.shard-index }}
1 change: 1 addition & 0 deletions requirements-tests-py3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ flake8-bugbear==21.4.3
flake8-pyi==20.10.0
isort==5.9.3
pytype==2021.08.11
tomli==1.1.0
4 changes: 2 additions & 2 deletions tests/check_consistent.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os
import re

import toml
import tomli

consistent_files = [
{"stdlib/@python2/builtins.pyi", "stdlib/@python2/__builtin__.pyi"},
Expand Down Expand Up @@ -165,7 +165,7 @@ def _strip_dep_version(dependency):
def check_metadata():
for distribution in os.listdir("stubs"):
with open(os.path.join("stubs", distribution, "METADATA.toml")) as f:
data = toml.loads(f.read())
data = tomli.loads(f.read())
assert "version" in data, f"Missing version for {distribution}"
version = data["version"]
msg = f"Unsupported Python version {version}"
Expand Down
6 changes: 3 additions & 3 deletions tests/mypy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from pathlib import Path
from typing import Dict, NamedTuple

import toml
import tomli

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

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

mypy_tests_conf = data.get("mypy-tests")
if not mypy_tests_conf:
Expand Down
4 changes: 2 additions & 2 deletions tests/stubtest_third_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import subprocess
import sys
import tempfile
import toml
import tomli
import venv
from glob import glob
from pathlib import Path
Expand Down Expand Up @@ -34,7 +34,7 @@ def get_mypy_req():

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

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