{"record":{"id":"d4f72c76c98106b9","repo":"astral-sh/ruff","slug":"find-name-in-mro-should-return-some-for-a-clas","errorCode":null,"errorMessage":"`find_name_in_mro` should return `Some` for a class literal","messagePattern":"`find_name_in_mro` should return `Some` for a class literal","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ty_python_semantic/src/types.rs","lineNumber":3647,"sourceCode":"                // ```pycon\n                // >>> class Foo:\n                // ...     def bar(self): pass\n                // >>> f = Foo()\n                // >>> f.bar is f.bar\n                // False\n                // ```\n                false\n            }\n            Type::KnownBoundMethod(_) => {\n                // Just a special case of `BoundMethod` really\n                // (this variant represents `f.__get__`, where `f` is any function)\n                false\n            }\n            Type::DataclassDecorator(_) | Type::DataclassTransformer(_) => false,\n            Type::NominalInstance(instance) => instance.is_singleton(db),\n            Type::PropertyInstance(_) | Type::SlotDescriptor(_) => false,\n            Type::Union(..) => {\n                // A single-element union, where the sole element was a singleton, would itself\n                // be a singleton type. However, unions with length < 2 should never appear in\n                // our model due to [`UnionBuilder::build`].\n                false\n            }\n            Type::Intersection(intersection) => intersection\n                .enum_complement(db, env)\n                .is_some_and(|complement| complement.is_singleton(db)),\n            Type::EnumComplement(complement) => complement.is_singleton(db),\n            Type::AlwaysTruthy | Type::AlwaysFalsy => false,\n            Type::TypeIs(type_is) => type_is.is_bound(db),\n            Type::TypeGuard(type_guard) => type_guard.is_bound(db),\n            Type::TypeForm(_) => false,\n            Type::TypedDict(_) => false,\n            Type::TypeAlias(alias) => alias.value_type(db).is_singleton(db, env),\n            Type::NewTypeInstance(newtype) => newtype.concrete_base_type(db).is_singleton(db, env),\n        }\n    }\n","sourceCodeStart":3629,"sourceCodeEnd":3665,"githubUrl":"https://github.com/astral-sh/ruff/blob/15f3fe6b15a5f00172f34b0f542f8ea277f5a586/crates/ty_python_semantic/src/types.rs#L3629-L3665","documentation":"For `type[Any]`-style SubclassOf-dynamic values, attribute lookup first checks `type`'s own class-level members so data descriptors like `__mro__` and `__bases__` resolve to their real types instead of collapsing to Any. find_name_in_mro on a class literal is guaranteed to return Some (a place, possibly undefined) because the MRO terminates in object; the expect enforces that guarantee for the class literal of KnownClass::Type.","triggerScenarios":"Member access on a `type[Any]`/`type[Unknown]` value (e.g., `t.__mro__` where `t: type[Any]`) when lookup on the `type` class literal returns None - i.e., the `type`/`object` MRO could not be walked in the current environment.","commonSituations":"Broken, partial, or hidden typeshed: custom search paths or vendored stubs that override builtins and drop `object` from the MRO; unsupported Python versions whose stub set fails to resolve `type`.","solutions":["Inspect the environment: run with verbose logging and check the resolved search paths; remove any vendored/partial stub override of builtins or object","Retry with a different --python-version to see whether that version's stubs resolve `type` correctly","If the environment looks standard, file a ty issue with the search-path setup and the member name being looked up"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before checking, confirm the standard environment resolves builtins:\n// (shell) ty check --verbose my_file.py 2>&1 | grep -i 'search path'\n// Ensure `builtins`/`object` resolve from the real typeshed before trusting type[Any] member access.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not vendor partial stubs over builtins/object in python search paths","Verify search-path configuration (`ty check --verbose`) when results look nonsensical","Pin a supported --python-version whose stub set is complete"],"tags":["rust","ty","types","mro","member-lookup","typeshed","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-14T05:17:10.506Z"}