mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-27 13:22:11 +08:00
Move Python 2-only stubs to @python2 directory (#5660)
This commit is contained in:
@@ -21,7 +21,7 @@ consistent_files = [
|
||||
{"stdlib/@python2/builtins.pyi", "stdlib/@python2/__builtin__.pyi"},
|
||||
{"stdlib/threading.pyi", "stdlib/_dummy_threading.pyi"},
|
||||
]
|
||||
metadata_keys = {"version", "python2", "python3", "requires", "extra_description", "obsolete_since"}
|
||||
metadata_keys = {"version", "python2", "requires", "extra_description", "obsolete_since"}
|
||||
allowed_files = {"README.md"}
|
||||
|
||||
|
||||
@@ -176,7 +176,6 @@ def check_metadata():
|
||||
for key in data:
|
||||
assert key in metadata_keys, f"Unexpected key {key} for {distribution}"
|
||||
assert isinstance(data.get("python2", False), bool), f"Invalid python2 value for {distribution}"
|
||||
assert isinstance(data.get("python3", True), bool), f"Invalid python3 value for {distribution}"
|
||||
assert isinstance(data.get("requires", []), list), f"Invalid requires value for {distribution}"
|
||||
for dep in data.get("requires", []):
|
||||
assert isinstance(dep, str), f"Invalid dependency {dep} for {distribution}"
|
||||
|
||||
@@ -18,6 +18,8 @@ import re
|
||||
import sys
|
||||
import toml
|
||||
import tempfile
|
||||
from glob import glob
|
||||
from pathlib import Path
|
||||
from typing import Dict, NamedTuple
|
||||
|
||||
PY2_NAMESPACE = "@python2"
|
||||
@@ -101,13 +103,18 @@ def parse_version(v_str):
|
||||
|
||||
|
||||
def is_supported(distribution, major):
|
||||
with open(os.path.join(THIRD_PARTY_NAMESPACE, distribution, "METADATA.toml")) as f:
|
||||
dist_path = Path(THIRD_PARTY_NAMESPACE, distribution)
|
||||
with open(dist_path / "METADATA.toml") as f:
|
||||
data = dict(toml.loads(f.read()))
|
||||
if major == 2:
|
||||
# Python 2 is not supported by default.
|
||||
return bool(data.get("python2", False))
|
||||
return bool(data.get("python2", False)) or (dist_path / "@python2").exists()
|
||||
# Python 3 is supported by default.
|
||||
return bool(data.get("python3", True))
|
||||
return has_py3_stubs(dist_path)
|
||||
|
||||
|
||||
def has_py3_stubs(dist: Path) -> bool:
|
||||
return len(glob(f"{dist}/*.pyi")) > 0 or len(glob(f"{dist}/[!@]*/__init__.pyi")) > 0
|
||||
|
||||
|
||||
def add_files(files, seen, root, name, args, exclude_list):
|
||||
|
||||
@@ -9,8 +9,6 @@ stdlib/builtins.pyi
|
||||
stdlib/typing.pyi
|
||||
|
||||
# third_party stubs with constructs that pytype doesn't yet support:
|
||||
stubs/fb303/fb303/FacebookService.pyi
|
||||
stubs/scribe/scribe/scribe.pyi
|
||||
stubs/paramiko/paramiko/_winapi.pyi
|
||||
stubs/paramiko/paramiko/win_pageant.pyi
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ def run_stubtest(dist: Path) -> None:
|
||||
with open(dist / "METADATA.toml") as f:
|
||||
metadata = dict(toml.loads(f.read()))
|
||||
|
||||
# Ignore stubs that don't support Python 2
|
||||
if not bool(metadata.get("python3", True)) or not has_py3_stubs(dist):
|
||||
# Ignore stubs that don't support Python 3
|
||||
if not has_py3_stubs(dist):
|
||||
return
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
|
||||
Reference in New Issue
Block a user