{"record":{"id":"102f2c12e2822278","repo":"astral-sh/ruff","slug":"the-meta-type-of-an-instance-like-type-should-alwa","errorCode":null,"errorMessage":"The meta-type of an instance-like type should always have an MRO","messagePattern":"The meta-type of an instance-like type should always have an MRO","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ty_python_semantic/src/types.rs","lineNumber":3771,"sourceCode":"                    _ => Some(\n                        class\n                            .class_member(db, env, name, policy)\n                            .map_type(|member| property_wrapper_descriptor(db, env, name, member)),\n                    ),\n                }\n            }\n\n            Type::GenericAlias(alias) if alias.is_typed_dict(db) => {\n                Some(alias.origin(db).typed_dict_member(\n                    db,\n                    env,\n                    Some(alias.specialization(db)),\n                    name,\n                    policy,\n                ))\n            }\n\n            Type::GenericAlias(alias) => Some(\n                ClassType::from(*alias)\n                    .class_member(db, env, name, policy)\n                    .map_type(|member| property_wrapper_descriptor(db, env, name, member)),\n            ),\n\n            Type::SubclassOf(subclass_of_ty) => {\n                subclass_of_ty.find_name_in_mro_with_policy(db, env, name, policy)\n            }\n\n            // Note: `super(pivot, owner).__class__` is `builtins.super`, not the owner's class.\n            // `BoundSuper` should look up the name in the MRO of `builtins.super`.\n            Type::BoundSuper(_) => KnownClass::Super\n                .to_class_literal(db, env)\n                .find_name_in_mro_with_policy(db, env, name, policy),\n\n            // We eagerly normalize type[object], i.e. Type::SubclassOf(object) to `type`,\n            // i.e. Type::NominalInstance(type). So looking up a name in the MRO of\n            // `Type::NominalInstance(type)` is equivalent to looking up the name in the","sourceCodeStart":3753,"sourceCodeEnd":3789,"githubUrl":"https://github.com/astral-sh/ruff/blob/15f3fe6b15a5f00172f34b0f542f8ea277f5a586/crates/ty_python_semantic/src/types.rs#L3753-L3789","documentation":"class_namespace_member looks a name up on the meta-type of a class; the expectation is that the meta-type of an instance-like type always has an MRO, so find_name_in_mro_with_policy must return Some. The expect fires when that MRO walk returns None for the class literal being used as the lookup anchor.","triggerScenarios":"Instance/class member lookup where the metaclass's MRO cannot be produced: circular or malformed class hierarchies, stubs with missing bases, or class tables that are stale after incremental edits.","commonSituations":"Hand-edited or generated stub files with broken `__bases__` chains; exotic metaclasses; LSP incremental rechecks where class metadata changed mid-session.","solutions":["Reduce to the class plus attribute access that panics and file a ty issue","Inspect the class's metaclass and base chain (cycles, missing bases in stubs) and fix the source or stub definitions","As a contributor: return an undefined place instead of unwrapping when the MRO walk fails, so lookup degrades gracefully"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| check_file(&db, file)));\nmatch result {\n    Ok(diags) => diags,\n    Err(payload) => { log::warn!(\"ty panicked on member lookup in {}: {:?}\", file, payload); vec![] }\n}","preventionTips":["Keep stub files' class hierarchies acyclic and complete (every base resolvable)","Regenerate rather than hand-edit stubs with metaclass bases","Report the class plus attribute access if the hierarchy looks valid - the fix belongs in ty's MRO fallback"],"tags":["rust","ty","types","mro","member-lookup","metaclass","panic"],"backgroundTag":"mro-lookup-returned-none","analyzedSha":"15f3fe6b15a5f00172f34b0f542f8ea277f5a586","analyzedAt":"2026-08-20T16:33:49.445Z","contentChangedAt":"2026-08-20T16:33:49.445Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}