mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-21 10:32:08 +08:00
Drop support for Python 2 (#8272)
This commit is contained in:
@@ -3,22 +3,13 @@
|
||||
# For security (and simplicity) reasons, only a limited kind of files can be
|
||||
# present in /stdlib and /stubs directories, see README for detail. Here we
|
||||
# verify these constraints.
|
||||
|
||||
# In addition, for various reasons we need the contents of certain files to be
|
||||
# duplicated in two places, for example stdlib/@python2/builtins.pyi and
|
||||
# stdlib/@python2/__builtin__.pyi must be identical. In the past we used
|
||||
# symlinks but that doesn't always work on Windows, so now you must
|
||||
# manually update both files, and this test verifies that they are
|
||||
# identical. The list below indicates which sets of files must match.
|
||||
from __future__ import annotations
|
||||
|
||||
import filecmp
|
||||
import os
|
||||
import re
|
||||
|
||||
import tomli
|
||||
|
||||
consistent_files = [{"stdlib/@python2/builtins.pyi", "stdlib/@python2/__builtin__.pyi"}]
|
||||
metadata_keys = {"version", "requires", "extra_description", "obsolete_since", "no_longer_updated", "tool"}
|
||||
tool_keys = {"stubtest": {"skip", "apt_dependencies", "ignore_missing_stub"}}
|
||||
allowed_files = {"README.md"}
|
||||
@@ -47,16 +38,7 @@ def check_stdlib() -> None:
|
||||
assert entry == "VERSIONS", f"Unexpected file in stdlib root: {entry}"
|
||||
assert name.isidentifier(), "Bad file name in stdlib"
|
||||
else:
|
||||
if entry == "@python2":
|
||||
continue
|
||||
assert_stubs_only(os.path.join("stdlib", entry))
|
||||
for entry in os.listdir("stdlib/@python2"):
|
||||
if os.path.isfile(os.path.join("stdlib/@python2", entry)):
|
||||
name, ext = os.path.splitext(entry)
|
||||
assert name.isidentifier(), "Bad file name in stdlib"
|
||||
assert ext == ".pyi", "Unexpected file in stdlib/@python2 root"
|
||||
else:
|
||||
assert_stubs_only(os.path.join("stdlib/@python2", entry))
|
||||
|
||||
|
||||
def check_stubs() -> None:
|
||||
@@ -82,15 +64,6 @@ def check_same_files() -> None:
|
||||
_, ext = os.path.splitext(file)
|
||||
if ext == ".pyi" and os.path.islink(file):
|
||||
raise ValueError(no_symlink.format(file))
|
||||
for file1, *others in consistent_files:
|
||||
f1 = os.path.join(os.getcwd(), file1)
|
||||
for file2 in others:
|
||||
f2 = os.path.join(os.getcwd(), file2)
|
||||
if not filecmp.cmp(f1, f2):
|
||||
raise ValueError(
|
||||
"File {f1} does not match file {f2}. Please copy it to {f2}\n"
|
||||
"Run either:\ncp {f1} {f2}\nOr:\ncp {f2} {f1}".format(f1=file1, f2=file2)
|
||||
)
|
||||
|
||||
|
||||
_VERSIONS_RE = re.compile(r"^([a-zA-Z_][a-zA-Z0-9_.]*): [23]\.\d{1,2}-(?:[23]\.\d{1,2})?$")
|
||||
@@ -121,8 +94,6 @@ def check_versions() -> None:
|
||||
def _find_stdlib_modules() -> set[str]:
|
||||
modules = set()
|
||||
for path, _, files in os.walk("stdlib"):
|
||||
if "@python2" in path:
|
||||
continue
|
||||
for filename in files:
|
||||
base_module = ".".join(os.path.normpath(path).split(os.sep)[1:])
|
||||
if filename == "__init__.pyi":
|
||||
|
||||
Reference in New Issue
Block a user