From c19ab9bcb831d7af941574f70167e936d08a366a Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Fri, 9 Oct 2026 21:32:32 +0100 Subject: [PATCH 1/2] Fx self-check on macOS --- mypy/util.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mypy/util.py b/mypy/util.py index d6a8b1eccef3..5e0a1117d9db 100644 --- a/mypy/util.py +++ b/mypy/util.py @@ -1011,6 +1011,7 @@ def get_available_threads() -> int: affinity = os.sched_getaffinity(0) if PSUTIL_AVAILABLE and (psutil.LINUX or psutil.WINDOWS or psutil.FREEBSD): # Currently not supported on macOS and NetBSD. + assert sys.platform != "darwin" # for self-check affinity = psutil.Process().cpu_affinity() assert cpu_count is not None From 246f9ab6c4b0eb3b867ac305fc6a5b697768df14 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Fri, 9 Oct 2026 21:44:35 +0100 Subject: [PATCH 2/2] Use if (and explain better) --- mypy/util.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mypy/util.py b/mypy/util.py index 5e0a1117d9db..58a4c11b96a6 100644 --- a/mypy/util.py +++ b/mypy/util.py @@ -1009,9 +1009,13 @@ def get_available_threads() -> int: # Not available on old Python versions on some platforms. if sys.platform == "linux": affinity = os.sched_getaffinity(0) - if PSUTIL_AVAILABLE and (psutil.LINUX or psutil.WINDOWS or psutil.FREEBSD): - # Currently not supported on macOS and NetBSD. - assert sys.platform != "darwin" # for self-check + if ( + PSUTIL_AVAILABLE + # This matches platform availability in psutil docs. + and (psutil.LINUX or psutil.WINDOWS or psutil.FREEBSD) + # This is redundant, but needed for self-check. + and sys.platform != "darwin" + ): affinity = psutil.Process().cpu_affinity() assert cpu_count is not None