Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pyrefly/lib/alt/class/class_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 17 additions & 0 deletions pyrefly/lib/test/class_overrides.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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#"
Expand Down
Loading