diff --git a/requirements_minimal.txt b/requirements_minimal.txt index 29690b592a..a6f3d645d0 100644 --- a/requirements_minimal.txt +++ b/requirements_minimal.txt @@ -6,4 +6,4 @@ tbump~=6.11 coverage~=7.12 pytest pytest-cov~=7.0 -mypy +mypy; platform_python_implementation!="PyPy" diff --git a/tests/test_raw_building.py b/tests/test_raw_building.py index 969178c30b..fdd86032a5 100644 --- a/tests/test_raw_building.py +++ b/tests/test_raw_building.py @@ -19,7 +19,6 @@ from typing import Any from unittest import mock -import mypy.build import pytest import tests.testdata.python3.data.fake_module_with_broken_getattr as fm_getattr @@ -37,6 +36,13 @@ object_build_class, ) +try: + import mypy.build + + HAS_MYPY = True +except ImportError: + HAS_MYPY = False + DUMMY_MOD = build_module("DUMMY") @@ -173,6 +179,7 @@ def mocked_sys_modules_getitem(name: str) -> types.ModuleType | CustomGetattr: assert not err +@pytest.mark.skipif(not HAS_MYPY, reason="This test requires mypy") def test_missing__dict__(): # This shouldn't raise an exception. object_build_class(DUMMY_MOD, mypy.build.ModuleNotFound)