From fcb0dc3a208bf98c4972ef3b208f36baf9ffc96c Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Tue, 23 Dec 2025 22:04:44 +0000 Subject: [PATCH] Move PyPy check before mypy imports --- mypy/main.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mypy/main.py b/mypy/main.py index 6136319ef22f9..864fe4b4febf6 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -14,6 +14,14 @@ from io import TextIOWrapper from typing import IO, TYPE_CHECKING, Any, Final, NoReturn, TextIO +if platform.python_implementation() == "PyPy": + sys.stderr.write( + "ERROR: Running mypy on PyPy is not supported yet.\n" + "To type-check a PyPy library please use an equivalent CPython version,\n" + "see https://github.com/mypyc/librt/issues/16 for possible workarounds.\n" + ) + sys.exit(2) + from mypy import build, defaults, state, util from mypy.config_parser import ( get_config_module_names, @@ -41,14 +49,6 @@ if TYPE_CHECKING: from _typeshed import SupportsWrite -if platform.python_implementation() == "PyPy": - sys.stderr.write( - "ERROR: Running mypy on PyPy is not supported yet.\n" - "To type-check a PyPy library please use an equivalent CPython version,\n" - "see https://github.com/mypyc/librt/issues/16 for possible workarounds.\n" - ) - sys.exit(2) - orig_stat: Final = os.stat MEM_PROFILE: Final = False # If True, dump memory profile