From 1e25866b238e4935b0ef015c4848dfb74274f7c7 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 28 Jun 2023 12:29:13 +0200 Subject: [PATCH] Improve pytype compatibility handling (#10377) --- tests/README.md | 2 ++ tests/pytype_test.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/README.md b/tests/README.md index af8653f46..e81afd4b7 100644 --- a/tests/README.md +++ b/tests/README.md @@ -72,6 +72,8 @@ for this script. Note: this test cannot be run on Windows systems unless you are using Windows Subsystem for Linux. +It also requires a Python version < 3.11 as pytype does not yet support +Python 3.11 and above. Run using: ```bash diff --git a/tests/pytype_test.py b/tests/pytype_test.py index 2b3265497..a1465e737 100755 --- a/tests/pytype_test.py +++ b/tests/pytype_test.py @@ -24,10 +24,16 @@ import pkg_resources from parse_metadata import read_dependencies -assert sys.platform != "win32" +if sys.platform == "win32": + print("pytype does not support Windows.", file=sys.stderr) + sys.exit(1) +if sys.version_info >= (3, 11): + print("pytype does not support Python 3.11+ 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] # noqa: E402 -from pytype.imports import typeshed # type: ignore[import] # noqa: E402 +from pytype import config as pytype_config, load_pytd # type: ignore[import] +from pytype.imports import typeshed # type: ignore[import] TYPESHED_SUBDIRS = ["stdlib", "stubs"] TYPESHED_HOME = "TYPESHED_HOME"