mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-19 09:32:49 +08:00
Optional pytype install on Windows (no CI) (#12669)
This commit is contained in:
@@ -71,9 +71,7 @@ for this script.
|
||||
|
||||
## pytype\_test.py
|
||||
|
||||
Note: this test cannot be run on Windows
|
||||
systems unless you are using Windows Subsystem for Linux.
|
||||
It also requires a Python version < 3.13 as pytype does not yet support
|
||||
Note: This test cannot be run on Python version < 3.13 as pytype does not yet support
|
||||
Python 3.13 and above.
|
||||
|
||||
Run using:
|
||||
|
||||
@@ -14,30 +14,32 @@ will also discover incorrect usage of imported modules.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
assert sys.platform != "win32", "pytype isn't yet installed in CI, but wheels can be built on Windows"
|
||||
if sys.version_info >= (3, 13):
|
||||
print("pytype does not support Python 3.13+ yet.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
import argparse
|
||||
import importlib.metadata
|
||||
import inspect
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
from collections.abc import Iterable, Sequence
|
||||
|
||||
from packaging.requirements import Requirement
|
||||
|
||||
from _metadata import read_dependencies
|
||||
from _utils import SupportedVersionsDict, parse_stdlib_versions_file, supported_versions_for_module
|
||||
|
||||
if sys.platform == "win32":
|
||||
print("pytype does not support Windows.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
if sys.version_info >= (3, 13):
|
||||
print("pytype does not support Python 3.13+ yet.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
# pytype is not py.typed https://github.com/google/pytype/issues/1325
|
||||
from pytype import config as pytype_config, load_pytd # type: ignore[import]
|
||||
from pytype.imports import typeshed # type: ignore[import]
|
||||
|
||||
from _metadata import read_dependencies
|
||||
from _utils import SupportedVersionsDict, parse_stdlib_versions_file, supported_versions_for_module
|
||||
|
||||
TYPESHED_SUBDIRS = ["stdlib", "stubs"]
|
||||
TYPESHED_HOME = "TYPESHED_HOME"
|
||||
_LOADERS = {}
|
||||
|
||||
@@ -7,6 +7,7 @@ import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from importlib.util import find_spec
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
@@ -127,11 +128,11 @@ def main() -> None:
|
||||
else:
|
||||
print(colored("\nSkipping stubtest since mypy failed.", "yellow"))
|
||||
|
||||
if sys.platform == "win32":
|
||||
print(colored("\nSkipping pytype on Windows. You can run the test with WSL.", "yellow"))
|
||||
else:
|
||||
if find_spec("pytype"):
|
||||
print("\nRunning pytype...")
|
||||
pytype_result = subprocess.run([sys.executable, "tests/pytype_test.py", path])
|
||||
else:
|
||||
print(colored("\nSkipping pytype on Windows. You need to install it first: `pip install pytype`.", "yellow"))
|
||||
|
||||
cases_path = test_cases_path(stub if folder == "stubs" else "stdlib")
|
||||
if not cases_path.exists():
|
||||
|
||||
@@ -69,8 +69,6 @@ def run_mypy_as_subprocess(directory: str, platform: str, version: str) -> Retur
|
||||
"--custom-typeshed-dir",
|
||||
".",
|
||||
]
|
||||
if directory == "tests" and platform == "win32":
|
||||
command.extend(["--exclude", "tests/pytype_test.py"])
|
||||
result = subprocess.run(command, capture_output=True, text=True)
|
||||
if result.stderr:
|
||||
print_error(result.stderr)
|
||||
|
||||
Reference in New Issue
Block a user