From 50ccf90d6a431d14d4c8ccb2ef9792114e02bf09 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Fri, 25 Sep 2026 15:28:51 +0100 Subject: [PATCH] Reduce max protocol stack size to 20 --- mypy/types.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mypy/types.py b/mypy/types.py index def2f9f207fdf..dd9c2b543cde8 100644 --- a/mypy/types.py +++ b/mypy/types.py @@ -224,10 +224,9 @@ class SentinelValue(NamedTuple): # Maximum protocol subtyping assumptions depth. We need this to avoid infinite # recursion for protocols that are genuinely undecidable, see testDivergingProtocol. -# Note we set very large cut-off for now, since some numerical libraries currently -# use ~25 assumptions, and we want to avoid false negatives with them. We may be able -# to reduce this in the future if we will optimize our callable unification logic. -MAX_PROTOCOL_DEPTH: Final = 40 +# We set a conservative cut-off, since some numerical libraries currently +# use ~10 assumptions, and we want to avoid false negatives with them. +MAX_PROTOCOL_DEPTH: Final = 20 class TypeOfAny: