diff --git a/mypy/util.py b/mypy/util.py index d6a8b1eccef3..58a4c11b96a6 100644 --- a/mypy/util.py +++ b/mypy/util.py @@ -1009,8 +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. + 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