Skip to content

Do not use --ignore-missing-stubs in stubtest_stdlib - #6403

Closed
Akuli wants to merge 3 commits into
python:masterfrom
Akuli:missing-stubs
Closed

Akuli wants to merge 3 commits into
python:masterfrom
Akuli:missing-stubs

Conversation

@Akuli

@Akuli Akuli commented Nov 27, 2021 •

Copy link
Copy Markdown
Collaborator

Fixes #6401

Most of the diff was created by a script that searches for "foo is not present in stub" errors in GitHub Actions logs, finds the ones that occur for all platforms and/or for all versions, and writes them to the correct files.

This PR is intended to be auto-generated. It is probably easiest to review commit by commit. Manual fixes will follow in separate pull requests.

@Akuli
Akuli marked this pull request as draft November 27, 2021 19:29
import re

platforms = ["linux", "win32", "darwin"]
versions = ["py36", "py37", "py38", "py39", "py310"]

entries_by_pv = {}
for p in platforms:
    for v in versions:
        p_name = {"linux": "ubuntu", "darwin": "macos", "win32": "windows"}[p]
        v_name = "3." + v.replace("py3", "")
        if v_name == "3.9":
            v_name = "3.9.7"

        entries = set()
        with open(f"la/Check stdlib with stubtest ({p_name}-latest, {v_name})/6_Run stubtest.txt") as file:
            for line in file:
                m = re.search(r"error: (.*) is not present in stub$", line.strip())
                if m:
                    entries.add(m.group(1))
        entries_by_pv[p, v] = entries

def remove_intersection(sets):
    sets = list(sets)
    result = set(sets[0])
    for s in sets[1:]:
        result &= s
    for s in sets:
        for r in result:
            s.remove(r)
    return result

common_to_all = remove_intersection(entries_by_pv.values())

common_to_version = {}
for v in versions:
    common_to_version[v] = remove_intersection([
        entries
        for (p, v2), entries in entries_by_pv.items()
        if v == v2
    ])

common_to_platform = {}
for p in platforms:
    common_to_platform[p] = remove_intersection([
        entries
        for (p2, v), entries in entries_by_pv.items()
        if p == p2
    ])

def write(fname, entries):
    with open(f"tests/stubtest_allowlists/{fname}.txt", "a") as file:
        file.write("\n# Missing from stubs, found by removing --ignore-missing-stub\n")
        for i in sorted(entries):
            file.write(i + "\n")

write("py3_common", common_to_all)
for v, entries in common_to_version.items():
    write(v, entries)
for p, entries in common_to_platform.items():
    write(p, entries)
for (p, v), entries in entries_by_pv.items():
    write(p + "-" + v, entries)
@Akuli

Akuli commented Nov 29, 2021

Copy link
Copy Markdown
Collaborator Author

I'll close this for now, and make a new similar pull request later once #6424 is merged. This way I can be sure that the pull request doesn't add unnecessary allowlist entries, as there's ridiculously many of them anyway.

@Akuli Akuli closed this Nov 29, 2021
@Akuli
Akuli deleted the missing-stubs branch November 29, 2021 13:34
@Akuli
Akuli restored the missing-stubs branch November 29, 2021 13:34
@Akuli
Akuli deleted the missing-stubs branch December 5, 2021 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stubtest: disable --ignore-missing-stubs for stdlib?

1 participant