From 1da911fd3553a966125a6aad4145b5304e814990 Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Sun, 17 Oct 2021 18:54:38 -0700 Subject: [PATCH 1/3] Allow mypy to run self check on PyPy --- mypy-requirements.txt | 2 +- mypy/build.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mypy-requirements.txt b/mypy-requirements.txt index 96888e2211282..50e690b71c687 100644 --- a/mypy-requirements.txt +++ b/mypy-requirements.txt @@ -1,4 +1,4 @@ typing_extensions>=3.7.4 mypy_extensions>=0.4.3,<0.5.0 -typed_ast>=1.4.0,<1.5.0 +typed_ast>=1.4.0,<1.5.0; python_version<'3.8' tomli>=1.1.0,<1.2.0 diff --git a/mypy/build.py b/mypy/build.py index ba671d6ea7006..06d5ac3f72cf7 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -15,6 +15,7 @@ import gc import json import os +import platform import re import stat import sys @@ -201,8 +202,9 @@ def _build(sources: List[BuildSource], stderr: TextIO, extra_plugins: Sequence[Plugin], ) -> BuildResult: - # This seems the most reasonable place to tune garbage collection. - gc.set_threshold(150 * 1000) + if platform.python_implementation() == 'CPython': + # This seems the most reasonable place to tune garbage collection. + gc.set_threshold(150 * 1000) data_dir = default_data_dir() fscache = fscache or FileSystemCache() From fb552a95aac0d5a0f0d8a8cb6d22505e30575319 Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Sun, 17 Oct 2021 21:46:04 -0700 Subject: [PATCH 2/3] Re-add typed_ast for py2 tests --- test-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test-requirements.txt b/test-requirements.txt index 9091914a5d2bf..2756dd11986fd 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -11,6 +11,7 @@ pytest-xdist>=1.34.0,<2.0.0 pytest-forked>=1.3.0,<2.0.0 pytest-cov>=2.10.0,<3.0.0 py>=1.5.2 +typed_ast>=1.4.0,<1.5.0; python_version>='3.8' virtualenv>=20.6.0 setuptools!=50 importlib-metadata>=4.6.1,<5.0.0 From 303095168822e2f4354a4a52951a82d3c590b648 Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Tue, 19 Oct 2021 07:05:31 -0700 Subject: [PATCH 3/3] Update FAQ about PyPy --- docs/source/faq.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/faq.rst b/docs/source/faq.rst index 43ba3d0d066e2..2a79498dd7929 100644 --- a/docs/source/faq.rst +++ b/docs/source/faq.rst @@ -201,7 +201,8 @@ the following aspects, among others: Does it run on PyPy? ********************* -No. MyPy relies on `typed-ast +Somewhat. With PyPy 3.8, mypy is at least able to type check itself. +With older versions of PyPy, mypy relies on `typed-ast `_, which uses several APIs that PyPy does not support (including some internal CPython APIs).