mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-05 17:37:41 +08:00
Drop Python 2 support in third-party stubs (#7703)
This commit is contained in:
@@ -15,7 +15,6 @@ import os
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
from glob import glob
|
||||
from pathlib import Path
|
||||
from typing import Dict, NamedTuple
|
||||
|
||||
@@ -93,20 +92,6 @@ def parse_version(v_str):
|
||||
return int(m.group(1)), int(m.group(2))
|
||||
|
||||
|
||||
def is_supported(distribution_path: Path, major: int) -> bool:
|
||||
data = dict(tomli.loads((distribution_path / "METADATA.toml").read_text()))
|
||||
if major == 2:
|
||||
# Python 2 is not supported by default.
|
||||
return bool(data.get("python2", False))
|
||||
# Python 3 is supported by default.
|
||||
return has_py3_stubs(distribution_path)
|
||||
|
||||
|
||||
# Keep this in sync with stubtest_third_party.py
|
||||
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):
|
||||
"""Add all files in package or module represented by 'name' located in 'root'."""
|
||||
full = os.path.join(root, name)
|
||||
@@ -326,22 +311,20 @@ def main():
|
||||
files_checked += len(files)
|
||||
|
||||
# Test files of all third party distributions.
|
||||
print("Running mypy " + " ".join(get_mypy_flags(args, major, minor, "/tmp/...")))
|
||||
for distribution in sorted(os.listdir("stubs")):
|
||||
if distribution == "SQLAlchemy":
|
||||
continue # Crashes
|
||||
if major != 2:
|
||||
print("Running mypy " + " ".join(get_mypy_flags(args, major, minor, "/tmp/...")))
|
||||
for distribution in sorted(os.listdir("stubs")):
|
||||
if distribution == "SQLAlchemy":
|
||||
continue # Crashes
|
||||
|
||||
distribution_path = Path("stubs", distribution)
|
||||
distribution_path = Path("stubs", distribution)
|
||||
|
||||
if not is_probably_stubs_folder(distribution, distribution_path):
|
||||
continue
|
||||
if not is_probably_stubs_folder(distribution, distribution_path):
|
||||
continue
|
||||
|
||||
if not is_supported(distribution_path, major):
|
||||
continue
|
||||
|
||||
this_code, checked = test_third_party_distribution(distribution, major, minor, args)
|
||||
code = max(code, this_code)
|
||||
files_checked += checked
|
||||
this_code, checked = test_third_party_distribution(distribution, major, minor, args)
|
||||
code = max(code, this_code)
|
||||
files_checked += checked
|
||||
|
||||
print()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user