From c296687159408033546aafb5bcc40bc2e6a545da Mon Sep 17 00:00:00 2001 From: Aayush Yash Date: Fri, 9 Oct 2026 22:56:27 +0530 Subject: [PATCH 1/2] fix: skip missing-super-call checks in TYPE_CHECKING blocks --- pyrefly/lib/alt/class/class_field.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pyrefly/lib/alt/class/class_field.rs b/pyrefly/lib/alt/class/class_field.rs index 1d77b01f8d..12d1fa12ca 100644 --- a/pyrefly/lib/alt/class/class_field.rs +++ b/pyrefly/lib/alt/class/class_field.rs @@ -4100,6 +4100,13 @@ impl<'ctx, 'answer, Ans: LookupAnswer> AnswersSolver<'ctx, 'answer, Ans> { if cls.module_path().is_interface() { return; } + if class_field + .ty() + .toplevel_func_metadata() + .is_some_and(|meta| meta.flags.is_in_type_checking_block) + { + return; + } // If any base derives from `Any`, we can't reliably tell whether the method // overrides a concrete parent method, so suppress the check. Gather this // across all bases first so the decision is independent of base order. From 5e3acd79e9076eca7dd1b2ac515fe47bff72219a Mon Sep 17 00:00:00 2001 From: Aayush Yash Date: Fri, 9 Oct 2026 22:56:39 +0530 Subject: [PATCH 2/2] test: cover missing-super-call in TYPE_CHECKING blocks --- pyrefly/lib/test/class_overrides.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pyrefly/lib/test/class_overrides.rs b/pyrefly/lib/test/class_overrides.rs index 645b7503e5..15ba99a15b 100644 --- a/pyrefly/lib/test/class_overrides.rs +++ b/pyrefly/lib/test/class_overrides.rs @@ -2338,6 +2338,23 @@ from stub import C, D "#, ); +testcase!( + test_missing_super_call_in_type_checking_block, + TestEnv::new().enable_missing_super_call_error(), + r#" +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + class Foo: + def __init__(self) -> None: + ... + + class Bar(Foo): + def __init__(self) -> None: + ... + "#, +); + testcase!( test_override_descriptor_method, r#"