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). 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() 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