From 9a2eae6316ad598ca37355b6abf6c2f56ecb8741 Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Tue, 3 Aug 2021 22:12:13 -0700 Subject: [PATCH] Skip overlapping overload checks in ignored files Resolves #9691 As mentioned in that issue, this is a huge performance win. On the codebase I'm currently working on, it halves a cacheless interpreted mypy runtime. The linked issue contains some more measurement. --- mypy/checker.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mypy/checker.py b/mypy/checker.py index ae93b8558add..a2b66b123aae 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -466,6 +466,13 @@ def check_overlapping_overloads(self, defn: OverloadedFuncDef) -> None: # At this point we should have set the impl already, and all remaining # items are decorators + if self.msg.errors.file in self.msg.errors.ignored_files: + # This is a little hacky, however, the quadratic check here is really expensive, this + # method has no side effects, so we should skip it if we aren't going to report + # anything. In some other places we swallow errors in stubs, but this error is very + # useful for stubs! + return + # Compute some info about the implementation (if it exists) for use below impl_type: Optional[CallableType] = None if defn.impl: