Skip to content

Commit 58d485b

Browse files
ilevkivskyihauntsaninja
authored andcommitted
Fail with an explicit error on PyPy (#20384)
Fixes mypyc/librt#21 Fail with an explicit user-friendly error on PyPy.
1 parent a4b31a2 commit 58d485b

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

mypy-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ typing_extensions>=4.6.0
44
mypy_extensions>=1.0.0
55
pathspec>=0.9.0
66
tomli>=1.1.0; python_version<'3.11'
7-
librt>=0.6.2
7+
librt>=0.6.2; platform_python_implementation != 'PyPy'

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ requires = [
99
"mypy_extensions>=1.0.0",
1010
"pathspec>=0.9.0",
1111
"tomli>=1.1.0; python_version<'3.11'",
12-
"librt>=0.6.2",
12+
"librt>=0.6.2; platform_python_implementation != 'PyPy'",
1313
# the following is from build-requirements.txt
1414
"types-psutil",
1515
"types-setuptools",
@@ -54,7 +54,7 @@ dependencies = [
5454
"mypy_extensions>=1.0.0",
5555
"pathspec>=0.9.0",
5656
"tomli>=1.1.0; python_version<'3.11'",
57-
"librt>=0.6.2",
57+
"librt>=0.6.2; platform_python_implementation != 'PyPy'",
5858
]
5959
dynamic = ["version"]
6060

setup.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,22 @@
55
import glob
66
import os
77
import os.path
8+
import platform
89
import sys
910
from typing import TYPE_CHECKING, Any
1011

1112
if sys.version_info < (3, 9, 0): # noqa: UP036, RUF100
1213
sys.stderr.write("ERROR: You need Python 3.9 or later to use mypy.\n")
1314
exit(1)
1415

16+
if platform.python_implementation() == "PyPy":
17+
sys.stderr.write(
18+
"ERROR: Running mypy on PyPy is not supported yet.\n"
19+
"To type-check a PyPy library please use an equivalent CPython version,\n"
20+
"see https://github.com/mypyc/librt/issues/16 for possible workarounds.\n"
21+
)
22+
exit(1)
23+
1524
# we'll import stuff from the source tree, let's ensure is on the sys path
1625
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
1726

test-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ identify==2.6.15
2222
# via pre-commit
2323
iniconfig==2.1.0
2424
# via pytest
25-
librt==0.6.2
25+
librt==0.7.3 ; platform_python_implementation != 'PyPy'
2626
# via -r mypy-requirements.txt
2727
lxml==6.0.2 ; python_version < "3.15"
2828
# via -r test-requirements.in

0 commit comments

Comments
 (0)